Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Any idea why checkpoint system no longer spawns on current stage?

Asked by 7 years ago

I recently finished my OBBY game and have left the stage system in place throughout the entire making of it. It was working last night and now it has stopped with nothing changing to it. I just want to know if there is anything wrong with my script or has there been any changes to the game mechanics.

Here is the code I am using.

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)

any help would be appreciated.

0
Use :Connect, not :connect. Programical 653 — 7y

Answer this question