I want to make something once the player's value goes up by 1. I made a server script that does that. But, it is not working. Here is the script:
wait(2) if game.Players.Player.leaderstats.Stage.Value +1 then print("value up") end
like I commented, use GetPropertyChangedSignal. im on phone rn so I cant test this but this is how it works.
local stage = game.Players.LocalPlayer.leaderstats.Stage stage:GetPropertyChangedSignal("Value"):Connect(function() print("value changed") end)
also, if this is a serverscript you need to get the specific Player. I think its better on a localscript anyway.
edit: you could also use this
stage.Changed:Connect(function() print("value changed") end)
and this would check to see if any property at all, not just Value has changed. but a leaderstat only has Value.
Assuming this script is going in ServerScriptService. You wrote the script wrong. It is supposed to be LocalPlayer not Player.
if game.Players.LocalPlayer.leaderstats.Stage.Value +1 then print("value up") end
I commonly use a connect to player system:
plr = game.Players.LocalPlayer
or
plr = script.Parent.Parent.Parent.Parent.Parent -- mostly only works for UI. Not always 5.
Also Works:
local plr = game.Players.LocalPlayer -- only for LocalScripts.
If this works, please accept my answer. Enjoy! :D
NOTE: This code will do the action below then any time the leaderstat stage value goes up by 1.
Edit: Use a script in ServerScriptService.
EDIT 2: Because this may not work:
local plr = game.Players.LocalPlayer local leaderstats2 = plr:WaitForChild("leaderstats") if plr.leaderstats2.Stage.Value +1 then print("value up") end
Otherwise, a simple solution is adding a:
while wait(.1) do
On the top instead of a simple wait code.