This is a decently simple script that completely works in studio. When I actually test it in game, it does't work. Does anyone know why?
script.Parent.Touched:connect(function(part) local leaderstats = game.Players.LocalPlayer:WaitForChild("leaderstats") local plr = game.Players:GetPlayerFromCharacter(part.Parent) if leaderstats["Raw Robloxs"].Value ~= 0 then wait(0.1) leaderstats.Money.Value = leaderstats.Money.Value + leaderstats["Raw Robloxs"].Value wait(0.1) leaderstats["Raw Robloxs"].Value = 0 end end)
'LocalPlayer' is for the client only, wich means that the server cannot access it.
A fix would be
script.Parent.Touched:connect(function(part) local plr = game.Players:GetPlayerFromCharacter(part.Parent) if plr then local leaderstats = plr:WaitForChild('leaderstats') if leaderstats["Raw Robloxs"].Value ~= 0 then wait(0.1) leaderstats.Money.Value = leaderstats.Money.Value + leaderstats["Raw Robloxs"].Value wait(0.1) leaderstats["Raw Robloxs"].Value = 0 end end
Btw, your scripts assumes that the 'hit' is a player, never do that, it might be another part, or a random brick.
If you have any more questions (or I made a typo), just ask