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.
01 | local oldMessage = "" |
02 | local minPlayers = 2 |
03 |
04 | function teleportAllPlayers() |
05 | local target = CFrame.new(workspace.TeleportTarget.Position) |
06 | for i, player in ipairs (game.Players:GetChildren()) do |
07 | player.Character.Torso.CFrame = target + Vector 3. new( 0 , i * 5 , 0 ) |
08 | player.Playing.Value = 1 |
09 | --add an offset of 5 for each character |
10 | end |
11 | end |
12 |
13 | function message(message) |
14 | if oldMessage ~ = message then |
15 | oldMessage = message |
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.
01 | --//Services |
02 | local RepStorage = game:GetService( "ReplicatedStorage" ) |
03 | local teams = game:GetService( "Teams" ) |
04 |
05 | --//Teams |
06 | local teamblue = Instance.new( "Team" ) |
07 | teamblue.Name = "TeamBlue" |
08 | teamblue.Parent = teams |
09 | teamblue.TeamColor = BrickColor.new( "Really blue" ) |
10 | local teamred = Instance.new( "Team" ) |
11 | teamred.Name = "TeamRed" |
12 | teamred.Parent = teams |
13 | teamred.TeamColor = BrickColor.new( "Really red" ) |
14 |
15 | --//Giving the player items |
Now make a function for when the round ends. In it put this.
1 | player.Backpack:remove() --// Removes the items from the players backpack |
01 | --//Teleporting the player |
02 |
03 | local blueteamspawn = game.Workspace.Part --//Change this to the target brick |
04 | local redteamspawn = game.Workspace.Part --//Change this part to the target brick |
05 |
06 | if player.Team = = teamblue then |
07 | if player.Character and player.Character:FindFirstChild( "HumanoidRootPart" ) then |
08 | player.Character.HumanoidRootPart.CFrame = blueteamspawn.CFrame + Vector 3. new( 0 , 5 , 0 ) |
09 | end |
10 | elseif player.Team = = teamred then |
11 | if player.Character and player.Character:FindFirstChild( "HumanoidRootPart" ) then |
12 | player.Character.HumanoidRootPart.CFrame = redteamspawn.CFrame + |
13 | Vector 3. new( 0 , 5 , 0 ) |
14 | end |
15 | 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
001 | local oldMessage = "" |
002 | local minPlayers = 2 |
003 |
004 | function teleportAllPlayers() --What do i have this for if i have teamspawning below in function EndRoundTakeWeps??? please comment below fang |
005 | local target = CFrame.new(workspace.TeleportTarget.Position) |
006 | for i, player in ipairs (game.Players:GetChildren()) do |
007 | player.Character.Torso.CFrame = target + Vector 3. new( 0 , i * 5 , 0 ) |
008 | player.Playing.Value = 1 |
009 | --add an offset of 5 for each character |
010 | end |
011 | end |
012 |
013 | function message(message) |
014 | if oldMessage ~ = message then |
015 | oldMessage = message |