Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make my obby's stages to add up?

Asked by 3 years ago

So I got the leaderboard, with the stages, but I don't know what script I should insert for all the checkpoints in my obby to make the stage number increase. Here's my serverscriptservice

game.Players.PlayerAdded:connect(function(player)
    local leaderstats = Instance.new("Model")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player 
    local stage = Instance.new("IntValue")
    stage.Name = "Stage"
    stage.Value = 0
    stage.Parent = leaderstats 

end)

If somebody could tell me the script that goes into checkpoints,that would be greatly appreciated

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

You can add a touch event with a debounce so when the player touches it, it will set it to that.

local debounce = false

checkpoint_name.Touched:Connect(function(hit)
    if debounce == false then
        if hit.Parent then
            if hit.Parent:FindFirstChild("Humanoid") then
                debounce = true
                local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
                plr.leaderstats.Stage.Value += 1
                local hum = hit.Parent.Humanoid
                -- as Speedmask said, I did not realise this, but the hum.Died function would infact cause a memory leakage. I have never made obbies before, so this is as far as I can get you. Sorry!
            end
        end
    end -- this should be 'end' not 'end)'.
end)

Any mistakes, sorry.

Hope this helps!

There were a few mistakes, and I have fixed them.

0
I added the script onto the checkpoint, and named the checkpoint checkpoint 1. I then changed the checkpoint_name to checkpoint1, and i tested it, but when i walked onto the checkpoint nothing changed dylindude 64 — 3y
0
Did you add a space in checkpoint1? If so, don't. I will test this for myself now. LikeableEmmec 470 — 3y
0
No, I didn't add a space in checkpoint 1, i just wrote it that way dylindude 64 — 3y
0
not sure what the other problem is, but is there anything stopping you from using roblox's standard spawnpoints? they're pretty common in obbies. also that hum.Died connection will cause a memory leak if not disabled :) Speedmask 661 — 3y
View all comments (2 more)
0
I have noticed a few errors, so I changed my script above. LikeableEmmec 470 — 3y
0
Just one more question, do I need to change the first checkpoint_name to checkpoint1? dylindude 64 — 3y
Ad

Answer this question