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

Why wont the player be teleported, yet it goes to the next line?

Asked by 4 years ago

So, I have a system where when a player is killed, and they are hostile, they go to jail. However, it wont teleport them to the jail.

function charAdd()
    print("respawn")
    local char = script.Parent.Parent.Character
    if script.Parent.Parent.TeamColor == BrickColor.new("Bright orange") then
        script.Parent.Parent.Neutral = false
        char:MoveTo(game.Workspace.PrisonBlock.Position + Vector3.new(0,1,0))
        print("waiting")
        wait(script.Parent.Parent.leaderstats.JailTime.Value)
        script.Parent.Parent.TeamColor = BrickColor.new("White")
        script.Parent.Parent.Neutral = true
        print("out of jail")
        script.Parent.Parent.leaderstats.JailTime.Value = 0
        char.Humanoid.Health = 0
    end

end
script.Parent.Parent.CharacterAdded:Connect(charAdd)

1 answer

Log in to vote
1
Answered by
harstud 218 Moderation Voter
4 years ago

I've never seen anyone use MoveTo to teleport a player. Use CFrame though.

function charAdd()
    print("respawn")
    local char = script.Parent.Parent.Character
    if script.Parent.Parent.TeamColor == BrickColor.new("Bright orange") then
        script.Parent.Parent.Neutral = false
        char:WaitForChild("HumanoidRootPart").CFrame = game.Workspace.PrisonBlock.CFrame
        print("waiting")
        wait(script.Parent.Parent.leaderstats.JailTime.Value)
        script.Parent.Parent.TeamColor = BrickColor.new("White")
        script.Parent.Parent.Neutral = true
        print("out of jail")
        script.Parent.Parent.leaderstats.JailTime.Value = 0
        char.Humanoid.Health = 0
    end

end
script.Parent.Parent.CharacterAdded:Connect(charAdd)

0
You can use MoveTo() as well. royaltoe 5144 — 4y
1
CFrame is just genuinely better I guess Rynappel 212 — 4y
Ad

Answer this question