How can I add 5 units to a players leaderstat value names “Potatoes” when they click a button?
Script:
local cstage = script.Parent
cstage.ClickDetector.MouseClick:Connect(function(cplr)
local mod = game.ServerStorage["EmptyPlot"]
local clone = mod:Clone()
clone.Parent = workspace
local empty = script.Parent
empty.Parent = game.ServerStorage
end)
Yeah, this is the script from ServerScriptService:
game.Players.PlayerAdded:Connect(function(Player)
local Stat = Instance.new("IntValue")
Stat.Name = "leaderstats"
local Score = Instance.new("IntValue")
Score.Name = "Potatoes"
Score.Value = 0
Score.Parent = Stat
Stat.Parent = Player
end)
game.Players.PlayerAdded:Connect(function(Player)
local Stat = Instance.new("IntValue")
Stat.Name = "leaderstats"
Stat.Parent = Player
local Score = Instance.new("IntValue")
Score.Name = "Potatoes"
Score.Value = 0
Score.Parent = Stat
end)
local cstage = script.Parent
local storage = game:GetService("ServerStorage")
cstage.ClickDetector.MouseClick:Connect(function(cplr)
local mod = storage["EmptyPlot"]
local clone = mod:Clone()
clone.Parent = workspace
local empty = script.Parent
empty.Parent = storage
--put this part where you want to award the player.
cplr.leaderstats.Potatoes.Value += 5
end)