Ok so, there is a script i’m using thats used for map selection and it works fine except it doesnt add a weld to the killer team like how I want, and if I try to make it add a weld to the killer team the whole thing breaks for some reason, whats the problem?
local intermission = 25
local roundLength = 250
local inRound = game.ReplicatedStorage.InRound
local staus = game.ReplicatedStorage.Status
local rep = game:GetService("ReplicatedStorage")
local blueTeam = game.Teams["Runner"]
local redTeam = game.Teams["Killer"]
local lobbyTeam = game.Teams.Lobby
local plrs = game:GetService("Players")
-- amount of players in each team
local BlueTeamCount
local RedTeamCount
-- amoungt of remaining players at the end of the round (and after round has started)
local remainingBlue
local remainingRed
inRound.Changed:Connect(function()
if inRound.Value == true then
else
for i, plr in pairs(game.Players:GetChildren()) do
local char = plr.Character
local humanRoot = char:WaitForChild("HumanoidRootPart")
local nameGui = char.Head:FindFirstChild("NameGUI")
humanRoot.CFrame = game.Workspace.lobbySpawn.CFrame
plr.Team = lobbyTeam
if nameGui then
nameGui.name.TextColor3 = Color3.new(1, 1, 1)
end
end
end
end)
local function round()
while true do
repeat
wait(1)
staus.Value = "Two or more players needed for a round to start..."
until #game.Players:GetChildren() >= 1
inRound.Value = false
for i = intermission, 0, -1 do
staus.Value = "Game will start in "..i.." seconds"
wait(1)
end
inRound.Value = true
BlueTeamCount = {}
RedTeamCount = {}
-- if you want there to be a delay right before the countdown starts, you can put a wait here
wait(5)
for i = roundLength, 0, -1 do
wait(1)
staus.Value = "Game will end in "..i.." seconds"
-- this is used to detect all the players in all teams, but we wont be using that
--local playing = {}
remainingBlue = {}
remainingRed = {}
for _, plr in pairs(game.Players:GetChildren()) do
if plr.Team == blueTeam then
if i == roundLength then
table.insert(BlueTeamCount,plr.Name)
end
table.insert(remainingBlue,plr.Name)
elseif plr.Team == redTeam then
local kb = game.ReplicatedStorage.KillBrick:Clone()
kb.Parent = plr.character
local weld = Instance.new("WeldConstraint")
weld.Parent = character
weld.Part0 = kb
weld.Part1 = character.Head
kb.CFrame = (character.Head.CFrame + Vector3.new(0,0,2))
kb.Orientation = Vector3.new (-90,0,0)
kb.IsInUse.Value = true
if i == roundLength then
table.insert(RedTeamCount,plr.Name)
end
table.insert(remainingRed, plr.Name)
end
end
-- if both teams have no more players left
if #remainingRed == 0 and #remainingBlue == 0 then
staus.Value = "Both Teams Lost!"
break
-- if red team has no more players left
elseif #remainingRed == 0 or #roundLength == 0 then
staus.Value = "The Runners Have Won!"
break
-- if blue team has no more players left
elseif #remainingBlue == 0 then
staus.Value = "The Killer Has Won!"
break
end
end
wait(2)
rep.RoundEnd:FireAllClients(BlueTeamCount,remainingBlue,RedTeamCount,remainingRed)
wait(6)
end
end
spawn(round)