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 5 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.

01function charAdd()
02    print("respawn")
03    local char = script.Parent.Parent.Character
04    if script.Parent.Parent.TeamColor == BrickColor.new("Bright orange") then
05        script.Parent.Parent.Neutral = false
06        char:MoveTo(game.Workspace.PrisonBlock.Position + Vector3.new(0,1,0))
07        print("waiting")
08        wait(script.Parent.Parent.leaderstats.JailTime.Value)
09        script.Parent.Parent.TeamColor = BrickColor.new("White")
10        script.Parent.Parent.Neutral = true
11        print("out of jail")
12        script.Parent.Parent.leaderstats.JailTime.Value = 0
13        char.Humanoid.Health = 0
14    end
15 
16end
17script.Parent.Parent.CharacterAdded:Connect(charAdd)

1 answer

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

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

01function charAdd()
02    print("respawn")
03    local char = script.Parent.Parent.Character
04    if script.Parent.Parent.TeamColor == BrickColor.new("Bright orange") then
05        script.Parent.Parent.Neutral = false
06        char:WaitForChild("HumanoidRootPart").CFrame = game.Workspace.PrisonBlock.CFrame
07        print("waiting")
08        wait(script.Parent.Parent.leaderstats.JailTime.Value)
09        script.Parent.Parent.TeamColor = BrickColor.new("White")
10        script.Parent.Parent.Neutral = true
11        print("out of jail")
12        script.Parent.Parent.leaderstats.JailTime.Value = 0
13        char.Humanoid.Health = 0
14    end
15 
16end
17script.Parent.Parent.CharacterAdded:Connect(charAdd)
0
You can use MoveTo() as well. royaltoe 5144 — 5y
1
CFrame is just genuinely better I guess Rynappel 212 — 5y
Ad

Answer this question