local part = script.Parent
local num = workspace.Checkpoints:FindFirstChild("1").Name
local db = false
local Checkpoint = script.Parent
local CheckpointNumber = Checkpoint.CheckpointValue.Value
part.Touched:Connect(function(person)
if game.Players:GetPlayerFromCharacter(person.Parent) and not db then
db = true
local plr = game.Players:GetPlayerFromCharacter(person.Parent)
local intvalue = plr:FindFirstChild("CurrentCheckpointNumber")
if CheckpointNumber == intvalue then
intvalue.Value = intvalue.Value + tonumber(num)
end
wait(1)
db = false
end
end)
Ok
-
You’re defining
script.Parent
twice -
Okay forget the
tonumber
since you already have a value inside the checkpoint
local db = false
local Checkpoint = script.Parent
local CheckpointNumber = Checkpoint.CheckpointValue.Value
part.Touched:Connect(function(person)
if game.Players:GetPlayerFromCharacter(person.Parent) and not db then
db = true
local plr = game.Players:GetPlayerFromCharacter(person.Parent)
local intvalue = plr:FindFirstChild("CurrentCheckpointNumber")
if CheckpointNumber == intvalue then --this part I don't know what you're trying to do? if the checkpoint that they're reaching is equal to the previous checkpoint?
intvalue.Value = CheckpointNumber
end
wait(1)
db = false
end
end)
What i’m trying to do here is if those 2 values are the same, the player is at the correct checkpoint and we can add so that the next checkpoint can check it.
Okay, then change my intvalue.Value = CheckpointNumber
to intvalue.Value = intValue.Value + 1
if you’re going to just go 1 by 1
Hmm, it still seems not to change it, it must not be reaching the if statement. I’ll try to debug
The values are not equal…? They both have the same value/name
Forgot to add .Value but now there’s a new error: Workspace.Checkpoints.1.Script:31: attempt to index number with ‘Value’
which has to do with this line: intvalue.Value = intvalue.Value + 1
Now it still won’t change the value smh and it had the correct print
show me your code bruh idk what’s happening
Why do we have a bunch of errors and this is something that’s very easy lol:
local db = false
local Checkpoint = script.Parent
local CheckpointNumber = Checkpoint.CheckpointValue.Value
Checkpoint.Touched:Connect(function(person)
if game.Players:GetPlayerFromCharacter(person.Parent) and not db then
db = true
local plr = game.Players:GetPlayerFromCharacter(person.Parent)
local intvalue = plr:FindFirstChild("CurrentCheckpointNumber").Value
if CheckpointNumber == intvalue then
print("Next Checkpoint")
intvalue = intvalue + 1
else
print("Not equal")
end
wait(1)
db = false
end
end)
ikr exactly. What prints here?
It prints this but it doesn’t add the 1. I’m not going to set the value to 2 because there are going to be over 100 checkpoints so that’s why there is +1
Is it a regular script?
Also try changing plr:FindFirstChild("CurrentCheckpointNumber").Value
back to plr:FindFirstChild("CurrentCheckpointNumber")
and just using intvalue.Value = intvalue.Value + 1
Guess what? It’s been solved. The issue was this line
Forgot to add the .value to intvalue. It can’t know if it’s equsl if it doesn’t know the value
Finally, thank goodness! Mark solution pls it helps alot!
Thank you for the help! This wll help a ton!