--Script
game.Players.PlayerAdded:Connect(function(player)
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local leadstats = player:WaitForChild("leaderstats")
local coinss = leadstats:WaitForChild("Coins")
local coins = coinss.Value
coins = coins + game.Lighting.cakes.Value
end
end)
end)
This giver will return your cakes to coins. everytime you earn a cake, the cakes.Value in Lighting will increase one by one and if you touch the giver, it will return you. BUt this script won't give it for some reason.
Can anybody explain the touch code easily and tell me why doesn't this work?
PS>I used
game.Players.PlayerAdded:Connect(function(player))
because i couldn't get LocalPlayer and leaderstats

1 comment
You dont need to detect player added to use player, you can use :GetPlayerFromCharacter(char) (i posted a answer using this.)