scroll up to the very top of the post
You should use debounce for functions that should only happen once in a while. Like the function can only happen once every 3 seconds. What you are doing in this script is disabling it forever.
What you could do is have a value inside the part with the stage number. And change the value to that when the player is standing on it.
You are not checking the player’s stage and if the spawn stage is 1 more than the player’s stage, so everyone can just keep touching it, wait out the debounce, and touch again
Reason being people aren’t supposed to collect multiple stages for one stage.
And also, people are going to need to be able to come back to stages, like in other difficulty chart obbies. I don’t want them to lose their progress when going backward.
It needs to do exactly what I have it doing except for everyone, simply put.
Which includes:
– You can only collect one point when you touch the checkpoint.
– When you go back, you don’t lose your progress.
– When you touch the part you respawn there.
which is exactly why you need to check if the checkpoint is the one the player is supposed to go to. either add an intvalue containing the stage number in the checkpoint, or just simply rename the checkpoint to the number. Then when a player touches it, check if checkpointStage = player.leaderstats.Stage.Value + 1
, if it is, then increment player stage, if not then just don’t do anything.
I already have it so they don’t lose their progress.
You don’t need a debounce, since after the first time the player touches the checkpoint, the stage number will no longer be one more than the player stage, so nothing happens
I don’t see why this isn’t working for all players then
Because there is a debounce. I need to make the debounce local somehow but I haven’t figured out how.
Or do something different. I don’t understand what you are proposing.
Checkpoint script:
local spawn = script.Parent
spawn.Touched:connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild(“Humanoid”) then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local checkpointData = game.ServerStorage:FindFirstChild(“CheckpointData”)
if not checkpointData then
checkpointData = Instance.new(“Model”, game.ServerStorage)
checkpointData.Name = “CheckpointData”
end
local checkpoint = checkpointData:FindFirstChild(tostring(player.userId))
if not checkpoint then
checkpoint = Instance.new("ObjectValue", checkpointData)
checkpoint.Name = tostring(player.userId)
player.CharacterAdded:connect(function(character)
wait()
character:WaitForChild("HumanoidRootPart").CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame + Vector3.new(0, 4, 0)
end)
end
checkpoint.Value = spawn
end
end)
that should work
Not what I need. I already have the checkpoint script
I just need it to work for everyone
Please tell me how I can get “checkpoint stage”
rename the checkpoint, or add an intvalue in the checkpoint containing the stage number
You need to find a different way. This “Debounce” just makes it so the script only works once globally.
Pretty much the point of this post.
You did not use .value
()()()()()
local Collected = {}
script.Parent.Touched:Connect(function(hit)
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Player then
if Collected[Player.UserId] then return end
Collected[Player.UserId] = true
Player:WaitForChild("leaderstats").Stage.Value += 1
end
end)
game.Players.PlayerRemoving:Connect(function(Player)
Collected[Player.UserId] = nil
end)