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

I tried to make it so when u got the certain tool then ur value goes +100 when u touched it. Help?

--This is a normal script

local db = true

script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") ~=nil then
		if db == true then
			db = false
			script.Parent.Transparency = 1
			local player = game.Players:GetPlayerFromCharacter(hit.Parent)
			game.Players.LocalPlayer.Character.BackPack:WaitForChild("Hamburger")
			player.leaderstats.Candy.Value = player.leaderstats.Candy.Value + 100
			script.Sound:Play()
			script.Parent:Destroy()

		
end
end

		
end)

1 answer

✓ Accepted answer

Line 9, change "game.Players.LocalPlayer" to "player". Server scripts can’t use LocalPlayer as it is nil to them, and the script already knows who the player is by "player".

1 comment

0

Thanks!

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