If someone could help me that would be great! I was wondering if someone could help me modify this script to that It has red and blue team spawns and when the round starts it gives team-specific weapons from lighting or some other place and then when the round ends it takes away the weapons.
local oldMessage = "" local minPlayers = 2 function teleportAllPlayers() local target = CFrame.new(workspace.TeleportTarget.Position) for i, player in ipairs(game.Players:GetChildren()) do player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0) player.Playing.Value = 1 --add an offset of 5 for each character end end function message(message) if oldMessage ~= message then oldMessage = message print(message) end end function playersCurrentlyPlaying() for i, player in ipairs(game.Players:GetChildren()) do if player.Playing.Value == 1 then return true end end return false end game:GetService('Players').PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() player.Playing.Value = 0 end) end) local playing = Instance.new("IntValue", player) playing.Value = 0 playing.Name = "Playing" end) while(true) do wait(10) if #game.Players:getPlayers() >= minPlayers then if playersCurrentlyPlaying() then message("Waiting for the current game to end...") else message("There are enough players for a new game! Teleporting...") wait(4) teleportAllPlayers() end else message("Waiting for more players...") end end
Make a function for when the round starts. Put the items you want for the player in a folder in ReplicatedStorage. In the function that runs when the round has started put this.
--//Services local RepStorage = game:GetService("ReplicatedStorage") local teams = game:GetService("Teams") --//Teams local teamblue = Instance.new("Team") teamblue.Name = "TeamBlue" teamblue.Parent = teams teamblue.TeamColor = BrickColor.new("Really blue") local teamred = Instance.new("Team") teamred.Name = "TeamRed" teamred.Parent = teams teamred.TeamColor = BrickColor.new("Really red") --//Giving the player items if player.Team == teamblue then local item1 = RepStorage:FindFirstChild("Name of tool") local item1clone = item1:Clone() item1clone.Parent = player.Backpack --//And so on for every item elseif player.Team = teamred then local item1 = RepStorage:FindFirstChild("Name of tool") local item1clone = item1:Clone() item1clone.Parent = player.Backpack --//And so on for every item end
Now make a function for when the round ends. In it put this.
player.Backpack:remove() --// Removes the items from the players backpack
--//Teleporting the player local blueteamspawn = game.Workspace.Part --//Change this to the target brick local redteamspawn = game.Workspace.Part --//Change this part to the target brick if player.Team == teamblue then if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then player.Character.HumanoidRootPart.CFrame = blueteamspawn.CFrame + Vector3.new(0,5,0) end elseif player.Team == teamred then if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then player.Character.HumanoidRootPart.CFrame = redteamspawn.CFrame + Vector3.new(0,5,0) end end
I believe this should work for creating the teams and giving the player items, but I don't know how to set teams. Make sure that the giving player items script is in a server script so that it can access the service "ReplicatedStorage" and "Teams".
For setting the teams look at this person's question. https://scriptinghelpers.org/questions/11208/how-can-i-split-up-teams-in-a-script
Dear Fang please look at this and revise, your work is much appricaited! So the script in whole should look something like this FN Fal is the gun i have in replicated storage
local oldMessage = "" local minPlayers = 2 function teleportAllPlayers() --What do i have this for if i have teamspawning below in function EndRoundTakeWeps??? please comment below fang local target = CFrame.new(workspace.TeleportTarget.Position) for i, player in ipairs(game.Players:GetChildren()) do player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0) player.Playing.Value = 1 --add an offset of 5 for each character end end function message(message) if oldMessage ~= message then oldMessage = message print(message) end end --Lookout below new code!!!!! function GiveTeamsWeapons() --//Services local RepStorage = game:GetService("ReplicatedStorage") local teams = game:GetService("Teams") --//Teams local teamblue = Instance.new("Team") teamblue.Name = "TeamBlue" teamblue.Parent = teams teamblue.TeamColor = BrickColor.new("Really blue") local teamred = Instance.new("Team") teamred.Name = "TeamRed" teamred.Parent = teams teamred.TeamColor = BrickColor.new("Really red") --//Giving the player items if player.Team == teamblue then local item1 = RepStorage:FindFirstChild("FN Fal") local item1clone = item1:Clone() item1clone.Parent = player.Backpack --//And so on for every item elseif player.Team = teamred then local item1 = RepStorage:FindFirstChild("FN Fal") local item1clone = item1:Clone() item1clone.Parent = player.Backpack --//And so on for every item end --New section for takin thos guns function EndRoundTakeWeps() player.Backpack:remove() --// Removes the items from the players backpack --//Teleporting the player --Hey PLEASE LOOOOK :3 If this is the team spawn then what about the code above about function teleportALLPlayers would i delete that? local blueteamspawn = game.Workspace.Part --//Change this to the target brick local redteamspawn = game.Workspace.Part --//Change this part to the target brick if player.Team == teamblue then if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then player.Character.HumanoidRootPart.CFrame = blueteamspawn.CFrame + Vector3.new(0,5,0) end elseif player.Team == teamred then if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then player.Character.HumanoidRootPart.CFrame = redteamspawn.CFrame + Vector3.new(0,5,0) end end --ends all the new stuff please function playersCurrentlyPlaying() for i, player in ipairs(game.Players:GetChildren()) do if player.Playing.Value == 1 then return true end end return false end game:GetService('Players').PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() player.Playing.Value = 0 end) end) local playing = Instance.new("IntValue", player) playing.Value = 0 playing.Name = "Playing" end) while(true) do wait(10) if #game.Players:getPlayers() >= minPlayers then if playersCurrentlyPlaying() then message("Waiting for the current game to end...") else message("There are enough players for a new game! Teleporting...") wait(4) teleportAllPlayers() end else message("Waiting for more players...") end end