I know this probably a dumb question to ask ,but I’ve only been scripting for a few months. I’m trying to make an obby prestige system that only works if the player is on a specific stage.
For some reason the prestige won’t add to the leaderstats and the stage number won’t reset when I set it to trigger at a specific number. Here’s the prestige script
local debounce = 0
local player = game.Players.LocalPlayer
function onTouched(hit)
if debounce == 0 then
debounce = 1
local check = hit.Parent:FindFirstChild("Humanoid")
if check ~= nil then
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
local stats = user:findFirstChild("leaderstats")
if player.stats:WaitForChild("Stage") == 2 then
local Prestige = stats:findFirstChild("Prestige")
Prestige.Value = Prestige.Value +1
wait(2)
end
end
debounce = 0
end
end
script.Parent.Touched:connect(onTouched)
The script seems to break down at the third ‘if then’ because when I set it to ‘stats ~= nil’ it works but exploiters can fly to the end and get the prestige without doing the obby.
if debounce == 0 then
debounce = 1
local check = hit.Parent:FindFirstChild("Humanoid")
if check ~= nil then
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
local stats = user:findFirstChild("leaderstats")
if user.stats:WaitForChild("Stage") == 2 then
local Prestige = stats:findFirstChild("Prestige")
Prestige.Value = Prestige.Value +1
wait(2)
end
end
debounce = 0
Since it seems the only error is trying to access the player as a LocalPlayer, I got rid of that and got the player object by referencing the user variable, which should be equal to the player.