I'm trying to make a script where it checks your leaderstats, and if your leaderstats value equals a curtain number, something happens in the workspace.
game.Players.PlayerAdded:Connect(function(player) if player.leaderstats.Levels.Value == 1 then wait(5) workspace.Level1:Destroy() end end)
What you are doing here is checking that when the player is added, if they are level 1 then destroy level 1. It checks once, but to detect changes we have to check if the level changes, we can do this using Changed.
foo.Changed:Connect(function() print(foo.Value) end)
Changed is showcased here, every time the value of foo changes, it prints the new value. We can use the same method to check if the level changes. Here's an example.
player.leaderstats.Levels.Changed:Connect(function() if player.leaderstats.Levels.Value == 1 then wait(5) workspace.Level1:Destroy() end end) if player.leaderstats.Levels.Value == 1 then wait(5) workspace.Level1:Destroy() end
Here we just make sure if the level changes, we check if its value is level 1. We check for the same thing after because if the level is already 1, then it won't be a change and it won't be picked up!