Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

6 comments

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

0

Did you add a space in checkpoint1? If so, don't. I will test this for myself now.

0

No, I didn't add a space in checkpoint 1, i just wrote it that way

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 :)

0

I have noticed a few errors, so I changed my script above.

0

Just one more question, do I need to change the first checkpoint_name to checkpoint1?

This discussion is preserved as it was. New answers, comments, and votes are closed.