Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

LocalScript breaks my leveling system?

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by 6 years ago

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)
0
thank you! PhaseBlaze -7 — 6y
Ad

Answer this question