Hello! I’m new to scripting and I need some of your help.
local Coins = game.Players.LocalPlayer:WaitForChild("leaderstats").Money
if Coins.Value < 0 then Coins.Value = 2 -- Should be giving the player money if it's below 0 --
end
This code doesn’t work. It just gives me nothing. Doesn’t even print.
It’s in starterplayerscripts btw
p.s i added a print to see if it’s actually working but it doesn’t print
local Player = game.Players.LocalPlayer
local leaderstats = Player:WaitForChild("leaderstats")
local Money = leaderstats:WaitForChild("Money")
if Money.Value <= 0 then
Money.Value = 2
end
local Player = game.Players.LocalPlayer
local leaderstats = Player:WaitForChild("leaderstats")
local Money = leaderstats:WaitForChild("Money")
if Money.Value <= 0 then
Money.Value = 2
end
If you don’t care about replication then this will work as a local script inside StarterPlayer/StarterCharacter scripts.
local Player = game.Players.LocalPlayer
local leaderstats = Player:WaitForChild("leaderstats")
local Money = leaderstats:WaitForChild("Money")
while task.wait() do
if Money.Value <= 0 then
Money.Value = 2
end
end
Just in case you want a server-sided version of the script:
--In ServerScriptService
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = plr:WaitForChild("leaderstats")
local Coins = leaderstats:WaitForChild("Money")
while Coins.Value <= 0 do
Coins.Value = 2
end
end)