Here is the script where I want it to give you 5 coins when you touch the part
local player = game.Players:GetPlayerFromCharacter() script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then player.leaderstats:FindFirstChild("Coins") Coins.Value = 5 end end)
And then the leaderboard script
game.Players.PlayerAdded:Connect(function(player) local stats = Instance.new("IntValue",player) stats.Name = "leaderstats" money = Instance.new("IntValue",stats) money.Name = "Coins" end)
This isn't working because you are setting player outside of the touched event and with no parameter, which results in nil.
And Coins wasn't set to anything.
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) local Coins=player.leaderstats:FindFirstChild("Coins") Coins.Value = 5 end end)