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

Why Is My Death Handler For An Obby Not Working?

Asked by 2 years ago

So I made a script Called "DeathHandler" In ServerScriptService and this is the code.

game.Players.PlayerAdded:Connect(function(player)
    print("Player Added Yay!")
    local Stage = player:WaitForChild("leaderstats"):WaitForChild("Stage")
    player.CharacterAdded:Connect(function(character)
        print("Character Added!")
        local StagePart = game.Workspace:FindFirstChild(Stage.Value)
        print(StagePart)
        character.HumanoidRootPart.Position = StagePart.Position + Vector3.new(0, 5, 0)
        print("Done!")
    end)
end)

The script is supposed to spawn a character on a stage part. The problem is that it doesn't do that. I have tried debugging it by print and I have tried doing it by Humanoid.Died as well. Also, Stage is a string value.

0
CFrame, not Position DeceptiveCaster 3761 — 2y

1 answer

Log in to vote
1
Answered by
Ludzik78 136
2 years ago

Hi! Try using CFrame instead. Fixed Code:

game.Players.PlayerAdded:Connect(function(player)
    print("Player Added Yay!")
    local Stage = player:WaitForChild("leaderstats"):WaitForChild("Stage")
    player.CharacterAdded:Connect(function(character)
        print("Character Added!")
        local StagePart = game.Workspace:FindFirstChild(Stage.Value) --Just incase use the tostring() function to make a it a string.
        print(StagePart)
        character.HumanoidRootPart.CFrame = CFrame * CFrame.new(0, 5, 0) --Its supposed to be times not add btw
        print("Done!")
    end)
end)
Ad

Answer this question