#I need help fact checking my code
15 messages · Page 1 of 1 (latest)
** You are now Level 1! **
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
local Players = game:GetService("Players")
local checkpoints = workspace.Checkpoints:GetChildren()
local function onCharacterAdded(character)
local player = Players:GetPlayerFromCharacter(character)
if player.leaderstats.Checkpoint.Value <= 0 then
return
end
for _, checkpoint in ipairs(checkpoints) do
if checkpoint:GetAttribute("Value") ~= player.leaderstats.Checkpoint.Value then
continue
end
task.wait(0.05)
character.HumanoidRootPart.CFrame = checkpoint.CFrame + Vector3.new(0, 4, 0)
end
end
local function onCheckpointTouched(otherPart, checkpoint)
local player = Players:GetPlayerFromCharacter(otherPart.Parent)
if player then
if player.leaderstats.Checkpoint.Value > checkpoint:GetAttribute("Value") then
return
end
if player.leaderstats.Checkpoint.Value + 1 ~= checkpoint:GetAttribute("Value") then
return
end
player.leaderstats.Checkpoint.Value = checkpoint:GetAttribute("Value")
end
end
Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local checkpoint = Instance.new("IntValue")
checkpoint.Name = "Checkpoint"
checkpoint.Parent = leaderstats
player.CharacterAdded:Connect(onCharacterAdded)
end)
for _, checkpoint in ipairs(checkpoints) do
checkpoint.Touched:Connect(function(otherPart)
onCheckpointTouched(otherPart, checkpoint)
end)
end
u made syntax errors
i tested this code in studio too
One message removed from a suspended account.