So I'm trying to stop this while true loop until the killer has died. Then when the killer has died, it will go back up and continue the loop once more. Here is my script. I'm trying to add the "killer has died" script part at the end:
``
game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) while true do local players = game.Players:GetPlayers() local killer = players[math.random(1,#players)] print(killer)
--edit chosen player-- local hat = game.ServerStorage.SpartanHelmet killer.Character.Humanoid:RemoveAccessories() killer.Character:WaitForChild("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=11356448" killer.Character:WaitForChild("Pants").PantsTemplate = "http://www.roblox.com/asset/?id=11357134" local hatclone = hat:Clone() killer.Character.Humanoid:AddAccessory(hatclone) --add speed,health and jumpheight-- killer.Character.Humanoid.WalkSpeed = 24 killer.Character.Humanoid.MaxHealth = 200 killer.Character.Humanoid.Health = 200 killer.Character.Humanoid.JumpHeight = 10 --show players name-- local swordsmansign = game.ServerStorage.SwordsmanSign:Clone() swordsmansign.Parent = killer.Character:FindFirstChild("Head") --show killers picture-- local Players = game:GetService("Players") local board = game.Workspace.Board.board.SurfaceGui.ImageLabel local userId = killer.UserId local thumbType = Enum.ThumbnailType.HeadShot local thumbSize = Enum.ThumbnailSize.Size420x420 local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize) board.Image = content board.Size = UDim2.new(0, 420, 0, 420) --show killers name-- local label = game.Workspace.LabelPart.SurfaceGui.TextLabel label.Text = killer.Name --mapchange-- local function selectmap() local maps = game.ReplicatedStorage.Maps:GetChildren() local selected = maps[math.random(1,#maps)] return selected end local randomizedmap = selectmap() print(randomizedmap) local randomizedmapclone = randomizedmap:Clone() randomizedmapclone.Parent = game.Workspace.Map -------------------------------------------------------Im trying to put the killer died here killer.Character.Humanoid.Died:Connect(function() print("killer died") end) end end)
end)