Hello! I created a local script for checkpoints, but for some reason it does not work locally. What could be the problem?
local player= game:WaitForChild("Players").LocalPlayer
local character = player.Character
local CheckpointData = script.CheckpointData
local CheckpointValue = script.CheckpointData.CheckpointValue
for i, v in pairs(game.Workspace.CheckpointFolder:GetChildren()) do
if v:IsA("Part") then
function onTouch()
CheckpointValue.Value=v.Position
end
v.Touched:connect(onTouch)
end
end
for i, v in pairs(game.Workspace.Obby.KillPart:GetChildren()) do
if v.Name == "KillPart" then
function onTouch()
player.Character:MoveTo(CheckpointValue.Value)
game.ReplicatedStorage.Death:FireServer(player)
end
end
end
v.Touched:connect(onTouch)
end

1 comment
You need to add a task.wait() to this otherwise you will probably time out.