players = game.Players:GetChildren() randomp = players[math.random(#players)] print(randomp.Name .. " is killer") game.Player.TeamColor = BrickColor.new("Bright red") for i,v in pairs(players) do if v.Name ~= randomp.Name then print(v.Name .. " is runner") game.Player.TeamColor = BrickColor.new("Bright blue") end end
How come this won't work? It CANNOT just go and kill the player so they spawn at a certain spawn. I'm making a deathrun recreation, so I need EXACT.
This is the full script:
-- NinjoOnline -- map = game.ServerStorage.Maps:GetChildren() h = Instance.new("Hint", game.Workspace) while true do if game.Players.NumPlayers > 1 then h.Text = "Deciding what map to play" wait(5) ranMap = math.random(1, #map) mapChosen = map[ranMap] h.Text = "Map Chosen: " .. mapChosen.Name wait(3) mapChosenClone = mapChosen:Clone() mapChosenClone.Parent = game.Workspace wait(1) ------------------------- -- Picks random killer -- ------------------------- players = game.Players:GetChildren() local randomp = players[math.random(1,#players)] print(randomp.Name .. " is killer") randomp.TeamColor = BrickColor.new("Bright red") randomp:LoadCharacter() for i,v in pairs(players) do if v.Name ~= randomp.Name then print(v.Name .. " is runner") v.TeamColor = BrickColor.new("Bright blue") v:LoadCharacter() end end --------------------------------- -- Teleport players to the map -- --------------------------------- rspawn = mapChosenClone.RunnerSpawn:GetChildren() kspawn = mapChosenClone.KillerSpawn:GetChildren() for i,v in pairs(game.Players:GetChildren()) do name = v.Name check = game.Workspace:FindFirstChild(name) if check then checkHumanoid = check:FindFirstChild("Humanoid") if checkHumanoid then check:MoveTo(rspawn[i].Position) end end end --------------------------- -- Game begins countdown -- --------------------------- for i = 3, 1, -1 do h.Text = "Game begins in: " .. i wait(1) end ------------------------------- -- Countdown till round ends -- ------------------------------- for i = 10, 1, -1 do h.Text = "Time left: " .. i wait(1) end h.Text = "The round has ended" wait(1) ------------------------------------ -- Teleport players back to lobby -- ------------------------------------ for i,v in pairs(game.Players:GetPlayers()) do v.Character:MoveTo(Vector3.new(108, 11.19, -29)) end wait(1) mapChosenClone:Destroy() ------------------------------------------------------ -- Tells the player their needs to br 1 more player -- ------------------------------------------------------ else h.Text = "You need 1 more player to join" end wait(1) end
Why can't it kill them? There is a method called :LoadCharacter()
which instantly respawns them.
players = game.Players:GetChildren() local randomp = players[math.random(1,#players)] print(randomp.Name .. " is killer") randomp.TeamColor = BrickColor.new("Bright red") randomp:LoadCharacter() for i,v in pairs(players) do if v.Name ~= randomp.Name then print(v.Name .. " is runner") v.TeamColor = BrickColor.new("Bright blue") v:LoadCharacter() end end