-This script already doesnt work... But what I am trying to make it able to do is Give the Bright Red Team A knife from ServerStorage And Bright Blue team a chance at getting A pistol Or A sniper. (50/50 Chance) NOT looking for a script to be activated on touch or clicked.
-Scrip has to have the capability to be able be pasted into workspace from serverstorage(Which i can handle) and give the players on teams red and blue their tools.
This is the script:
local Knife = game.ServerStorage.Cane
local Pistol = game.ServerStorage.Pistol
local Sniper = game.ServerStorage.Sniper
game.Players.PlayerAdded:connect(function(player)
if player.TeamColor == BrickColor.Red then
Knife:Clone().Parent = player.StarterGear
elseif player.TeamColor == BrickColor.Blue then
Pistol:Clone().Parent = player.StarterGear
end
end)
-However I want the tool to be able to be lost when they die.
I tried this recently but still did not work...
local Knife = game.ServerStorage.Knife
local Pistol = game.ServerStorage.Pistol
local Sniper = game.ServerStorage.Sniper
for _, player in pairs(game.Players:GetPlayers()) do
if player.TeamColor == BrickColor.Red then
Knife:Clone().Parent = player.Backpack
elseif player.TeamColor == BrickColor.Blue then
local rnd = math.random() --An empty math.random returns 0 or 1
if rnd == 0 then Pistol:Clone().Parent = player.Backpack else
Sniper:Clone().Parent = player.Backpack end
end
end

13 comments
Thanks for the help ill check it out and see if all goes well.
So far its not working, saying it needs another end ill edit the script and get back to you
You're right i forgot one end, i added it back - It's at line 10. It should work now.
stil didnt work, what I am doing if having the script also copy and pasted into workspace, hoping it will find the blue and red team players and give them there tools.
That is called Brute-forcing in our language. Anyway i re-edited my script so it should work now.
Ok, ill check it out
Sadly still not working, maybe its because the script is working on players that just joined? Would it be possible to re-route the script towards players already in the game/already on the team?
Yes, but that is off the topic of this question.
If you want I can just ask another question with that topic.
Actually, it isn't - my mistake. Another, and hopefully final, edit.
Still doesnt work...
Can't help then.
ok ill ask someone else but ill accept your answer because you tired