This is what I got.
Yes, but obviously the WaitForChild seems to be timing out.
Yeah, true.
Should not be happening. I’m also not sure why the value has to be a string value now, since the leaderboard handles that for everyone now.
Well, then the problem is my gsub. Try printing what my gsub returns and I can fix it from there.
game.Players.PlayerAdded:Connect(function(Player)
repeat
task.wait(0.5)
until Player:FindFirstChild("leaderstats")
local Cash = Player.leaderstats:WaitForChild("Cash")
Cash:GetPropertyChangedSignal("Value"):Connect(function()
print(string.gsub(Cash.Value, ",", ""))
if tonumber(string.gsub(Cash.Value, ",", "")) >= 500 then
print("Over 500")
end
end)
end)
Yea, Zed’s Tycoon Kit stopped receiving updates years ago I believe.
It doesn’t return anything bruh
Wait where do I put the return. Or did you already put it
I just tested this myself. I forgot that gsub returned a second value of how many commas were removed.
game.Players.PlayerAdded:Connect(function(Player)
repeat
task.wait(0.5)
until Player:FindFirstChild("leaderstats")
local Cash = Player.leaderstats:WaitForChild("Cash")
Cash:GetPropertyChangedSignal("Value"):Connect(function()
local amt = string.gsub(Cash.Value, ",", "")
if tonumber(amt) >= 500 then
print("Over 500")
end
end)
end)
Wait, it returned my cash.
The first line is my cash. 161,945,806
or 161million.
The only thing is that the number was comparing it with nil.
It should work properly if you used the tonumber(amt) instead of the tonumber(string.gsub(Cash.Value, “,”, “”)). I tested it myself and it worked perfectly fine for me. But might as well add another print.
game.Players.PlayerAdded:Connect(function(Player)
repeat
task.wait(0.5)
until Player:FindFirstChild("leaderstats")
local Cash = Player.leaderstats:WaitForChild("Cash")
Cash:GetPropertyChangedSignal("Value"):Connect(function()
local amt = string.gsub(Cash.Value, ",", "")
print(amt, tonumber(amt))
if tonumber(amt) >= 500 then
print("Over 500")
end
end)
end)
My game is broken, the collector isn’t working bruh
lol i have to try to fix it
Alright, I will be going to bed soon, but I will try and check again before I do. Just tell me if there are any problems.
Omg it works. the only thing is. I reseted the data for every single player that ever played the game lol
Well, hopefully, you had a backup for that, but I’m not sure why you reset all the data anyways.
The main reason it was broken was because of the datastore. So I just reset the script. Anyway not many players have gotten a ton of progress anyways.
if newPlayer:FindFirstChild("leaderstats") == nil then
local leaderstats = Instance.new("IntValue")
leaderstats.Parent = newPlayer
leaderstats.Name = "leaderstats"
local score = Instance.new("IntValue")
score.Parent = leaderstats
score.Name = "Score"
score.Value = 0
local captures = Instance.new("IntValue")
captures.Parent = leaderstats
captures.Name = "Captures"
captures.Value = 0
-- To crash the default Player List
local haxStr = Instance.new("StringValue")
haxStr.Parent = leaderstats
end
The purpose of making the ‘leaderstats’ an ‘IntValue’ object predates the existence of SetCoreGuiEnabled
.
Cash.Changed:Connect(function(NewCash)
local amt = string.gsub(NewCash, ",", "")
print(amt, tonumber(amt))
if tonumber(amt) >= 500 then
print("Over 500")
end
end)
Use Changed
for value objects.
Using GetPropertyChangedSignal is actually better in this case. I’m not sure why you would want to use Changed. GetPropertyChangedSignal allows me to detect when the value itself changes and nothing else.
https://developer.roblox.com/en-us/api-reference/event/IntValue/Changed
Please read the documentation of the ‘Changed’ event/signal for value objects, it only fires when the object’s ‘Value’ property changes.
Well, didn’t know that Changed worked like that on an IntValue as it works completely different on everything else, so thank you for that.