Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Specific Team Tool Giver. Any Help?

Asked by 9 years ago

I am looking for a script that can give a certain team a specific weapon without a brick needing to be touched or clicked. I am looking to give the Bright red Team A knife, and the Bright blue team a pistol. The knife and the pistol are both located inside ServerStorage. The knife and pistol need to be put into the players backpacks with it saving so when they die they lose the weapons. (No put weapons in team name scripts)

1BrickColor.new("Bright blue")
2 
3BrickColor.new("Bright red")

Or

1BrickColor.Blue --Transmutes to Bright blue
2 
3BrickColor.Red --Transmutes to Bright red
1game.ServerStorage.Knife:Clone()
2 
3game.ServerStorage.Pistol:Clone()

-I have tried many times at this but I could never get it work. The only thing I got to work was touching a button.

01off = false
02 
03function tuch(h)
04if off == false then
05off = true
06    if h.Parent:findFirstChild("Humanoid") ~= nil then
07    local c = script.Parent.Parent.Tools:getChildren()
08    for i = 1, #c do
09        if c[i].className == "HopperBin" or "Tool" then
10        c[i]:clone().Parent = game.Players:findFirstChild(h.Parent.Name).Backpack
11        wait(99999999)
12        off = false
13        end
14    end
15    end
16end
17end
18 
19script.Parent.touched:connect(tuch)

1 answer

Log in to vote
0
Answered by
Marios2 360 Moderation Voter
9 years ago

That is much simplier than you think. You just check for each player's TeamColor in a PlayerAdded event and give them weapons accordingly. Except said weapons get placed in StarterGear. That will do the rest for you.

In a script inside ServerScriptService:

01local knife = game.ServerStorage.Knife
02local gun = game.ServerStorage.Pistol
03 
04game.Players.PlayerAdded:connect(function(player) --When a player connects, do the following...
05    if player.TeamColor == BrickColor.Red then --When a player is assigned to Red
06        knife:Clone().Parent = player.StarterGear --If a tool is in StarterGear, it doesn't get lost on player death
07    else --If a player is blue instead
08        gun:Clone().Parent = player.StarterGear
09    end
10end)

Alternatively, you can give them the weapon in Backpack and do that every time the player's character is added with the CharacterAdded event. Here's what you'd do otherwise:

1game.Players.PlayerAdded:connect(function(player)
2    player.CharacterAdded:connect(function()
3    --Finish the rest
4    end)
5end)
0
I have 3 teams and are looking to only give to bright blue and bright red. Can i just change that else to elseif and add in if player.TeamColor == BrickColor.Blue then CarterTheHippo 120 — 9y
0
I am also looking for, (which I Should of mentioned sorry about that). Giving one weapon to the blue team but it is picked randomly to be a sniper or a pistol. CarterTheHippo 120 — 9y
0
However it didnt seem to work CarterTheHippo 120 — 9y
0
Make another question and i can answer it for you if you wish. Marios2 360 — 9y
Ad

Answer this question