Hello! I'm making an obby and new to scripting, I have a script that should increase the player's prestige by 1 and reset the player's stage to 0, however, it doesn't work.
Script:
local Prestige = workspace.PrestigeTest
Prestige.Touched:Connect(function(touch)
local humanoid
local player = game.Players:GetPlayerFromCharacter(touch.Parent)
if touch.Parent:FindFirstChild("Humanoid") then
humanoid = touch.Parent.Humanoid
end
if touch.Parent and touch.Parent.Parent:FindFirstChild("Humanoid") then
humanoid = touch.Parent.Parent.Humanoid
end
if humanoid and player then
if player.leaderstats.Stage.Value == 100 then
player.leaderstats.Prestige.Value = player.leaderstats.Prestige.Value + 1
player.leaderstats.Stage.Value = 0
end
end
end)
When I remove if player.leaderstats.Stage.Value == 100 then it works, but I want the player to only be able to prestige if they're at stage 100.

3 comments
When they are prestiging, does the leaderboards say they are on stage 100?
Where are you updating the Stage Value on the Server or the Client? If its on the Client, then the value between the Server and the Client are not the same so it wont run at 100 since it will remain 0 on the Server
The stage value saves to a datastore, and I also tried putting the script in ServerScriptService but it still doesn't work.