So in a game I am making I have a lederstat named "Toads" that is suposed to increase everytime you click with a custom made tool named "Mushroom" but for somereason it does not work.
Here are my scripts related to my leaderstats:
function playerAdded(plr)
local stats = Instance.new("IntValue", plr) stats.Name = "leaderstats"
local money = Instance.new("IntValue", stats) money.Name = "Toads" money.Value = 0
end
game.Players.PlayerAdded:connect(playerAdded)
tool.Activated:Connect(function() game.Players.Player1.leaderstats.Toads.Value = game.Players.Player1.leaderstats.Toads.Value + 1 end)
Hello, this script is for a surface gui.
plr = game:GetService("Players").LocalPlayer local leaderstats = Instance.new("IntValue", plr) leaderstats.Name = "leaderstats" local money = Instance.new("IntValue", stats) money.Name = "Money" money.Value = 0 gui = Put your designated path to the GUI button = GUI.Put your button path button.MouseButton1Down:connect(function() plr.leaderstats.Money.Value = plr.leaderstats.Money.Value +1
This works for a normal script and local script
Hey put this script i made in a LocalScript inside of StarterPlayerScripts:
plr = game.Players.LocalPlayer -- get the player (only works at a LocalScript) local stats = Instance.new("IntValue", plr) stats.Name = "leaderstats" local money = Instance.new("IntValue", stats) money.Name = "Toads" money.Value = 0 backpack = plr:WaitForChild("Backpack") -- will wait for the backpack loads tool = backpack.Tool -- get the tool inside the backpack tool.Activated:Connect(function() plr.leaderstats.Toads.Value = plr.leaderstats.Toads.Value + 1 end)
please study my script and see what is wrong with your