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

LocalScript breaks my leveling system?

So I have a brick that if touched then it changes the localplayers XP to 5000, levelling them up.

script.Parent.Parent.Touched:connect(function(brick)
	game.Players.LocalPlayer.XP.Value = 5000
end)

It works fine as a Script, and when I run it in studio, it works, levelling me up to level 2, however when I publish and play in game it does nothing, expected as it is a script.

So I copy and paste it onto a localscript and put it in the brick, but now it does nothing, in studio and in-game, help?

Edit: Yes I have checked for errors, in game, and in studio

1 answer

You defined the brick that touched the part but did not use it. This works:

script.Parent.Touched:connect(function(hit)
	local user = game.Players:GetPlayerFromCharacter(hit.Parent)
	user.Xp.Value = 5000
end)

1 comment

0

thank you!

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