Basically I have a boolvalue inside the player that denominates whether or not the player is in jail. If the value is true, (the value is changed by an arrest tool) then the player gets moved to a part (JailSpawn). Only thing is, I don't want to use teams. Can anyone help? I'm probably doing this all wrong, I'm new at scripting.
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) if player.Jailed.Value == true then character:MoveTo(game.Workspace.JailSpawn.Position) end end) end)
That's what I have so far. Thanks in advance.
You were extremely close. Roblox was just moving your character to the default spawn at the same time you were trying to move it to the jail spawn. The solution is to add a wait() before moving it. It's also recommended that you CFrame the torso rather than moving the entire character so that people won't spawn on top of the jail.
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) if player.Jailed.Value == true then wait(.1) local torso = character:WaitForChild("Torso") torso.CFrame = CFrame.new(game.Workspace.JailSpawn.Position+Vector3.new(0,3,0)) end end) end)