I want to make a custom jail cell command, with admin commands. I already have the admin commands, jail model and code for the command ready, but:
I can’t get the spawn point to work. When you initially jail the player with the /jail command, it works fine. They get killed and spawn in the jail. But when they reset, they spawn back at the world spawn points right after.
I’ve already tried adding a wait after the Humanoid.Died function, and I’ve tried moving the function in the PlayerAdded event, and the command’s function.
I need to get the player to always spawn inside of the jail cell when they reset when their IsJailed value is equal to true.
Any help is appreciated!
commands.jail = function(sender, arguments) local playerToJail = arguments if playerToJail then local plr = findPlayer(playerToJail) if plr then local jailClone = serverStorage.AdminCommands.Models.Jail:Clone() local playerFolder = Instance.new("Folder") playerFolder.Name = plr.Name playerFolder.Parent = workspace.AdminCommands.JailedPlayers plr.IsJailed.Value = true jailClone.PrimaryPart.CFrame = plr.Character.HumanoidRootPart.CFrame - Vector3.new(0, 2, 0) jailClone.Parent = playerFolder plr.Character:BreakJoints() plr.Character.Humanoid.Died:Connect(function() task.wait(2.6) plr.Character.HumanoidRootPart.Position = jailClone.SpawnPoint.Position + Vector3.new(0, 3, 0) end) end end end