I have a game where you advance to the next level by earning XP and when you have the designated amount of XP a part will be destroyed so you can go through it (Client sided).
I believe that it should work but I get no printed text etc. No error either.
LOCAL SCRIPT:
local plr = game:GetService("Players").LocalPlayer local function CheckIfEnough() if plr:WaitForChild("leaderstats").XP.Value >= 500 then print("Test") script.Parent.Parent.NextLevelBrick:Destroy() end end plr:WaitForChild("leaderstats").XP.Value.Changed:Connect(CheckIfEnough() -- If the xp value of a player changes it will run the function.
Listen to the changed event of the value instance, not the number itself. Also, do .Changed:Connect(CheckIfEnough)
because :Connect expects a function, but by including (), you are calling the function.
plr:WaitForChild("leaderstats").XP.Changed:Connect(CheckIfEnough)