script.Parent.Yes.MouseButton1Click:connect(function()
if game.Players.LocalPlayer.leaderstats.Stage.Value < 20 and db then
db = false
script.Parent.Question.Text = "YOU NEED ATLEAST 20 STAGES TO REBIRTH!"
wait(3)
script.Parent.Visible = false
open = false
db = true
elseif db then
game.ReplicatedStorage.Rebirth:FireServer()
script.Parent.Visible = false
open = false
end
end)
why is this showing an error on line 2 saying attempt to compare string and number?
That means game.Players.LocalPlayer.leaderstats.Stage.Value is a string. I don't know how leaderstats work but I think you've made it a string accidentally instead of a number.
Related
for i, v in pairs(Buttons:GetChildren()) do
local NewItem = BoughtItems:FindFirstChild(v.Item.value)
if NewItem ~= nil then
Items[NewItem.Name] = NewItem:Clone()
NewItem:Destroy()
else
v.ButtonPart.Transparency = 1
v.ButtonPart.CanCollide = false
v.ButtonPart.BillBoardGui.Frame.Visible = false
end
if v:FindFirstChild("Dependency") then
coroutine.resume(coroutine.create(function(
v.ButtonPart.Transparency = 1
v.ButtonPart.CanCollide = false
v.ButtonPart.BillBoardGui.Frame.Visible = false
if BoughtItems:WaitForChild(v.Dependency.Value, 100000)then
v.ButtonPart.Transparency = 0
v.ButtonPart.CanCollide = true
v.ButtonPart.BillBoardGui.Frame.Visible = true
end
end))
end
v.ButtonPart.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid")then
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Values.OwnerValue.Value == Player then
if v.ButtonPart.CanCollide == true and v.ButtonPart.Transparency == 0 then
if Player:WaitForChild("leaderstats").Cash.Value >= v.Price.Value then
Player.leaderstats.Cash.Value -= v.Price.Value
Items[v.Item.Value].Parent = BoughtItems
v:Destroy()
end
end
end
end
end)
end
how do i fix this the header is the problem i dont knw what it means so is there a fix to it for my tycoon if anyone knows pls comment (heres some random stuff since my post is mostly code) A brief Introduction to Copypasta. Copypasta means to copy a text or a part of the text from an existing manuscript and inclusion of that very text in an under-process manuscript by pasting. At present, the societies are going to be expanded with an enormous pattern.
Parenthesis always come in pairs. The error message already strongly suggests that you are missing a closing parenthesis for an opening one in line 38.
1 2 3
coroutine.resume(coroutine.create(function(
v.ButtonPart.Transparency = 1
v.ButtonPart.CanCollide = false
v.ButtonPart.BillBoardGui.Frame.Visible = false
if BoughtItems:WaitForChild(v.Dependency.Value, 100000)then
v.ButtonPart.Transparency = 0
v.ButtonPart.CanCollide = true
v.ButtonPart.BillBoardGui.Frame.Visible = true
end
end)) <--- one is missing
1 2
Use a text editor that autocompletes pairs or even better one that hightlights pairs in matching colors to avoid errors like this.
I was making custom chat system and I faced this "bug".
just textbox returns "", not nil.
and there is no any error. even without
string.len(script.Parent.Parent.message.Text) > 0
"if" part.
local db = false
local TextService = game:GetService("TextService")
script.Parent.MouseButton1Click:Connect(function ()
local plr = script.Parent.Parent.Parent.Parent.Parent.Parent
local dn = plr.Character.Humanoid.DisplayName
local muted = script.Parent.muted.Value
local mod = script.Parent.moderator.Value
if db == false and muted == false and string.len(script.Parent.Parent.message.Text) > 0 then
db = true
local ts = 16
local msg = script.Parent.Parent.chat.message0:Clone()
--problem line
msg.messageContent.Text = TextService:FilterStringAsync(script.Parent.Parent.message.Text, plr.UserId, "2")
if string.len(script.Parent.Parent.message.Text) > 130 then
ts = 14
end
msg.messageContent.TextSize = ts
--problem ends
local ps = msg.prefixes
ps.bot.Visible = false
local counter = game.ReplicatedStorage.ChatBlockStorage.counter.Value
msg.Name = "message" .. counter
msg.actualName.Text = "#" .. plr.Name
msg.displayName.Text = dn
msg.icon.Image = game.Players:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
msg.icon.ResampleMode = "Default"
if script.Parent.Parent.message.customIcon.locked.Visible == false then
msg.icon.Image = "http://www.roblox.com/asset/?id=" .. script.Parent.Parent.message.customIcon.Text
end
if msg.Name == "message1" then
mod = true
end
if mod == true then
ps.mod.Visible = true
end
counter += 1
script.Parent.Parent.message.Text = ""
wait(game.ReplicatedStorage.ChatBlockStorage.waitTime.Value)
db = false
end
end)
any ideas how to fix it?
Use the FocustLost event. Here is the roblox documentation on it.
Example:
script.Parent.FocusLost:Connect(function(enterPressed)
if enterPressed then
print("Focus was lost because enter was pressed!")
end
end)
Near the end of the code, you write
script.Parent.Parent.message.Text = ""
Would this not be the cause?
maybe you can do tostring(msg)?
this prob wont work
tostring("i like beans")
read more on strings here:https://developer.roblox.com/en-us/articles/String
read more on tostring() here: https://devforum.roblox.com/t/what-does-assert-and-tostring-do/1047653
(none are people i know but i looked through them and they have valid info)
good luck my brother
I'm sorry if this is a really simple or easy question, but I am trying to set the player leaderstat "Money" to 0, but it keeps coming back as the old value. The only thing that I can think of that may be causing this problem is that the moneyGain script is on repeat.
Here is my moneyGain script:
local playerMoney
while wait(0.24) do
local buttons = script.Parent.Parent.info.savedItems.Value.buttons:GetChildren()
for button = 1, #buttons, 1 do
if buttons[button].Parent.Parent.tycoon.Value ~= nil then
if buttons[button].Parent.Parent.tycoon.Value.info.owner ~= nil then
if buttons[button].jobDone.Value == true then
script.Parent.moneyEnforcer.enforce:Invoke(buttons[button].gainVal.Value)
end
end
end
end
--OWNERDOOR:
if script.Parent.Parent.info.owner.Value ~= nil then
script.Parent.moneyEnforcer.enforce:Invoke(1)
end
end
Here is my moneyEnforcer script:
local rs = game:GetService("ReplicatedStorage")
local dictionary = require(rs.dictionary)
local vipPlayers = dictionary.vipPlayers
script.enforce.OnInvoke = function(amount)
print(amount)
if script.Parent.Parent.info.player.Value ~= nil then
if game:GetService("GamePassService"):PlayerHasPass(script.Parent.Parent.info.player.Value, 25494219) then
amount = amount * 2
else
for i = 1, #vipPlayers, 1 do
if script.Parent.Parent.info.player.Value.Name == vipPlayers[i] then
amount = amount * 2
end
end
end
local playerMoney = script.Parent.Parent.info.player.Value.leaderstats.Money
script.Parent.Parent.info.player.Value.leaderstats.Money.Value = script.Parent.Parent.info.player.Value.leaderstats.Money.Value + amount
end
end
And here is the tycoon reseter:
local player = script.Parent.Parent.Parent.Parent.Parent.Parent
script.Parent.Parent.Parent.Visible = false
script.Parent.MouseButton1Click:Connect(function()
player.leaderstats.Money.Value = 0
script.Parent.Parent.Parent.Visible = false
local savedItems = player.claimedTycoon.Value.info.savedItems.Value
local builds = player.claimedTycoon.Value.activeBuilds:GetChildren()
local buttons = player.claimedTycoon.Value.activeButtons:GetChildren()
for i = 1, #builds, 1 do
builds[i].Parent = savedItems.builds
end
for j = 1, #buttons, 1 do
buttons[j].Parent = savedItems.buttons
end
savedItems.builds.dirtStarterBase.Parent = player.claimedTycoon.Value
player.claimedTycoon.Value.info:WaitForChild("activeWave").Value = 1
end)
I have tried putting the "script.Parent.Parent.info.player.Value.leaderstats.Money.Value = script.Parent.Parent.info.player.Value.leaderstats.Money.Value + amount" on the moneyGain script, but that made no difference.
Any help is appriciated!
I believe your problem is that you're setting the value of money from the client. When you change the value from a local script, it will not update on the server. To fix this update the value from the server
In tycoon reseter, try resetting the value from the server using a RemoteEvent
This script is from Roblox Studio and is in Lua. I have tried using separate scripts but when I do, they don't work because of the bool value. The scripts seem either not to respond to it or it just doesn't update correctly. I have attached the picture of the hierarchy from ROBLOX Studio. I am reasonably to new to Lua but I am familiar with the basic concepts. I also know the Roblox Studio Interface deeply. If anyone could help, that would be greatly appreciated. Thanks in advance.
local lockvalue = script.Parent.Lockdown.Value
lockvalue = false
local RobBank = script.Parent["Rob Bank"]
local ClickDetector = RobBank:WaitForChild("ClickDetector")
local BillboardCXZ = RobBank:WaitForChild("BillboardGui")
local Billboard = BillboardCXZ:WaitForChild("TextLabel")
local emergencylight1 = script.Parent.Parent.EmergencyLight.Toggle.Value
local emergencylight2 = script.Parent.Parent.EmergencyLight2.Toggle.Value
local emergencylight3 = script.Parent.Parent.EmergencyLight3.Toggle.Value
local alarm1 = script.Parent.Parent.Alarm1.AlarmSound
local alarm2 = script.Parent.ParentAlarm2.AlarmSound
local Notif1 = script.Parent.NotifcationScreen.SurfaceGui.Frame.Visible
local Notif2 = script.Parent.NotifcationScreen.SurfaceGui.Frame.TextButton.MouseButton1Click
print ("Values Loaded.")
local function lock()
print ("LOCK FUNCTION ACTIVATED")
emergencylight1 = true
emergencylight2 = true
emergencylight3 = true
alarm1:play()
alarm2:play()
lockvalue = true
Notif1 = true
end
local function unlock()
print ("UNLOCK FUNCTION ACTIVATED")
emergencylight1 = false
emergencylight2 = false
emergencylight3 = false
alarm1.stop()
alarm2:stop()
lockvalue = false
Notif1 = false
end
Notif2:Connect(function()
unlock()
print ("Unlocked Via Override")
end)
RobBank.ClickDetector.MouseClick:Connect(function(Player)
print ("Functioning")
if Player and Player.Character then
print ("Milestone 2")
if lockvalue == false then
print ("After Lock Value")
if Player.Team == game.Teams.Criminal then
print ("Team Check")
local clicks = Player:FindFirstChild("leaderstats")["Bounty"]
clicks.Value = clicks.Value + 500
local clicks2 = Player:FindFirstChild("leaderstats")["Cash"]
clicks2.Value = clicks2.Value + 2500
Billboard.TextColor3 = Color3.new(1,0,0)
lock()
wait(60)
unlock()
Billboard.TextColor3 = Color3.new(0,1,0)
else
print("Player Is not On Crim team.")
Billboard.Text = ("You are on the Wrong Team!")
wait(3)
Billboard.Text = ("Steal Cash")
end
else
Billboard.Text = ("Already been recently robbed!")
wait(3)
Billboard.Text = ("Steal Cash")
end
end
end)
In Lua, a variable can be a reference to a table which has children (key/value pairs):
local myTable = { }
myTable.myKey = true
However, if you refer to a single child (by its key) then it will evaluate and pass only the resulting value into the variable (not a reference to the key itself).
local newVar = myTable.myKey
print(newVar) -- true
newVar = false
print(newVar) -- false
print(myTable.myKey) -- true, because we never changed myKey
So in the following statement, emergencylight1 is probably the value 'true' or 'false' rather than being a reference to the property itself.
local emergencylight1 = script.Parent.Parent.EmergencyLight.Toggle.Value
Recommendation
Ensure your variables are references to an actual table, and then refer to a child of that table (by its key) when assigning a new value.
local emergencylighttoggle1 = script.Parent.Parent.EmergencyLight.Toggle
local emergencylighttoggle2 = script.Parent.Parent.EmergencyLight2.Toggle
local emergencylighttoggle3 = script.Parent.Parent.EmergencyLight3.Toggle
local function lock()
emergencylighttoggle1.Value = true
emergencylighttoggle2.Value = true
emergencylighttoggle3.Value = true
end
local function unlock()
emergencylighttoggle1.Value = false
emergencylighttoggle2.Value = false
emergencylighttoggle3.Value = false
end
Error:
16:16:03.496 - Workspace.Storeroom.Pile of Crates.Wood Crate.Script:17: attempt to index field 'Parent' (a nil value)
Script:
local db = true
local clickdetector = script.Parent:WaitForChild('ClickDetector')
clickdetector.MouseClick:Connect(function(plr)
local randomizer = math.random(1,6)
if randomizer == 1 or 2 or 3 then
script.Parent:Destroy()
local gift = game:GetService("ReplicatedStorage"):WaitForChild("Blue Keycard")
if db == true then
db = false
gift:Clone().Parent = plr.Backpack
wait(1)
db = true
end
end
if randomizer == 4 or 5 then
script.Parent:Destroy()
local gift = game:GetService("ReplicatedStorage"):WaitForChild("Red Keycard")
if db == true then
db = false
gift:Clone().Parent = plr.Backpack
wait(1)
db = true
end
end
if randomizer == 6 then
script.Parent:Destroy()
local gift = game:GetService("ReplicatedStorage"):WaitForChild("Green Keycard")
if db == true then
db = false
gift:Clone().Parent = plr.Backpack
wait(1)
db = true
end
end
end)
if randomizer == 1 or 2 or 3 then
if randomizer == 4 or 3 then
These lines won't work as you think it should. It doesn't check if randomizer value is in some set of predefined values. Expression randomizer == 1 or 2 or 3 evaluates (depending on randomizer exact value) either to true or to 2, which is interpreted as true in if/then construct.
If you really want to check the value against the list, you should do something like:
local set1 = {1=true, 2=true, 3=true}
local set2 = {4=true, 5=true}
-- somewhere much later
if set1[randomizer] then .. end
Start with fixing this issue.