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.
01 | function 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 + Vector 3. 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 |
16 | end |
17 | script.Parent.Parent.CharacterAdded:Connect(charAdd) |
I've never seen anyone use MoveTo to teleport a player. Use CFrame though.
01 | function 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 |
16 | end |
17 | script.Parent.Parent.CharacterAdded:Connect(charAdd) |