this is the script:
part = script.Parent part.Touched:connect(function(hit)
player = game:GetService("Players").LocalPlayer
stats = player:findFirstChild("leaderstats")
coins = stats:findFirstChild("Coins") coins.Value = coins.Value + 1
end)
and yes I have a leaderboard script
Whenever doing a touched function you can not use LocalPlayer as it only works in LocalScripts
This code here should work:
script.Parent.Touched:connect(function(part) if game.Players:FindFirstChild(part.Parent.Name) then local plr = game.Players:FindFirstChild(part.Parent.Name) plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 1 end end)