Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

This script doesn't work in local or normal?

Its a script for a game im making and the best way to explain it without dropping too much details. Think of it like a crate you open you find money the crate goes away.

script.Parent.Touched:connect(function(h)
	if h.Parent.Name == "Opener" then
		wait(0.2)
		game.Players.LocalPlayer.leaderstats.Grass.Value = game.Players.LocalPlayer.leaderstats.Cash.Value +1
		script.Parent:Destroy()
	elseif h.Parent.Name == "BetterOpener" then
		wait(0.2)
		game.Players.LocalPlayer.leaderstats.Grass.Value = game.Players.LocalPlayer.leaderstats.Cash.Value +2
		script.Parent:Destroy()
	end 
end)

--Needs Fixing

now the problem is when its in a localscript it doesn't work in studio or in game. But when its just a normal script it works in studio but not in game. How do I fix it?

1 answer

That's because it's not in the character but the Local Player itself, try changing game.Players.LocalPlayer.leaderstats.Grass.Value to game.Players.LocalPlayer.Character.leaderstats.Grass.Value

This discussion is preserved as it was. New answers, comments, and votes are closed.