#Obby Chechkpoints script

1 messages · Page 1 of 1 (latest)

dreamy aurora
#

i tried watching a tutorial on yt but it didnt work so idk
the script on the video was:
local Checkpoints = workspace.Checkpoints

game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder",plr)
leaderstats.Name = "leaderstats"
local Checkpoints = Instance.new("IntValue",leaderstats)
Checkpoints.Name = "Stage"
Checkpoints.value = 1

plr.CharacterAdded:Connect(function(char)
    wait()
    if Checkpoints.Value > 1 then
        char:MoveTo(Checkpoints:FindFirstChild(Checkpoints.Value - 1).Position)
    end
end)

end)

for i, v in pairs(Checkpoints:GetChildren()) do
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local char = hit.Parent
local plr = game.Players:GetPlayerFromCharacter(char)
local Checkpoint = plr.leaderstats.Stage
if tonumber(v.Name) == Checkpoints.Value then
Checkpoints.Value += 1
end
end
end)
end

scenic vector
#

if no then do thast

dreamy aurora
#

yea i did

scenic vector
#

oh then idk

dreamy aurora
#

like first checkpoint to 1

#

then it goes on

dreamy aurora
#

uh it just doesnt do anything when i step on the checkpoints

coral sail
#

so this part of the code works? plr.CharacterAdded:Connect(function(char)
wait()
if Checkpoints.Value > 1 then
char:MoveTo(Checkpoints:FindFirstChild(Checkpoints.Value - 1).Position)
end
end)
end)

dreamy aurora
#

nothing is working like i dont respawn at the checkpoints and even in the leaderboard i dont get like +1 stage

#

but i never codded

coral sail
#

this has to be with capital V, so Checkpoints.Value = 1 not Checkpoints.value = 1

dreamy aurora
#

i'll try

coral sail
#

obviusoly this part of the code doesnt work because u set the checkpoints value to be = 1 but when your checking in the CharacterAdded you check for value higher than 1 so it nevers runs: plr.CharacterAdded:Connect(function(char)
wait()
if Checkpoints.Value > 1 then
char:MoveTo(Checkpoints:FindFirstChild(Checkpoints.Value - 1).Position)
end
end)
end)

#

so this never runs: char:MoveTo(Checkpoints:FindFirstChild(Checkpoints.Value - 1).Position)

#

so try setting Checkpoints.value = 2

#

for example

dreamy aurora
#

ok

coral sail
#

and second one

#

local Checkpoints = workspace.Checkpoints

#

local Checkpoints = Instance.new("IntValue",leaderstats)

#

you set same name for 2 different variables

#

I recommend naming the actual physical checkpoints in workspace to be "local worldCheckpoints = workspace.Checkpoints"

grim stirrupBOT
#

studio** You are now Level 1! **studio

coral sail
#

for example

#

and then in your for i,v loop

#

change it to

#

for i, v in pairs(worldCheckpoints:GetChildren()) do

dreamy aurora
#

alr

grim stirrupBOT
#

studio** You are now Level 1! **studio

coral sail
#

let me know if it works

dreamy aurora
#

ye i'm trying

coral sail
#

Tu es francais?

dreamy aurora
#

jure t français

dreamy aurora
coral sail
#

non, j'etudie la France au lycee

dreamy aurora
#

oh ok

coral sail
#

xd

#

so its working?

dreamy aurora
coral sail
#

So like

#

you have 2 variables

#

named same

#

so the script doesnt know which one you are referring to

#

so at the very beginning of your script change this local Checkpoints = workspace.Checkpoints

#

to example this local worldCheckpoints= workspace.Checkpoints

#

and then change this

#

for i, v in pairs(Checkpoints:GetChildren()) do

#

to this for i, v in pairs(worldCheckpoints:GetChildren()) do

dreamy aurora
#

local worldCheckpoints = workspace.Checkpoints

game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder",plr)
leaderstats.Name = "leaderstats"
local Checkpoints = Instance.new("IntValue",leaderstats)
Checkpoints.Name = "Stage"
Checkpoints.Value = 2

plr.CharacterAdded:Connect(function(char)
    wait()
    if Checkpoints.Value > 1 then
        char:MoveTo(Checkpoints:FindFirstChild(Checkpoints.Value - 1).Position)
    end
end)

end)

for i, v in pairs(worldCheckpoints:GetChildren()) do
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local char = hit.Parent
local plr = game.Players:GetPlayerFromCharacter(char)
local Checkpoint = plr.leaderstats.Stage
if tonumber(v.Name) == Checkpoints.Value then
Checkpoints.Value += 1
end
end
end)
end

#

did this but it still doesnt work

livid thorn
#
char:MoveTo(Checkpoints:FindFirstChild(Checkpoints.Value - 1).Position)
#

U messed up

#

Supposed to be worldCheckPoints:FindFirstChild(...)

#

Since youre trying to move to an int value

dreamy aurora
#

alr i'll try

dreamy aurora
livid thorn
#
local Checkpoint = plr.leaderstats.Stage
            if tonumber(v.Name) == Checkpoints.Value then
                Checkpoints.Value += 1
            end
#

Checkpoint and Checkpoints are not the same

#

Mispelled prob

dreamy aurora
#

oh

grim stirrupBOT
#

studio** You are now Level 2! **studio

dreamy aurora
#

but it still doesn't work

livid thorn
#

can u just show ss

dreamy aurora
#

alr

livid thorn
#

Ew

#

Flashbang

#

I thought you changed to checkpoint

#

If you see an underline on a code then its error

dreamy aurora
#

oh

#

oooo tyysm it works now

raw canyon
livid thorn
#

A small delay until player is loaded