-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
All you need here is a math.random variable to then choose Pistol or sniper.
And if you want the tool to dissapear when a player dies, put it in Backpack instead.
local Knife = game.ServerStorage.Cane local Pistol = game.ServerStorage.Pistol local Sniper = game.ServerStorage.Sniper game.Players.PlayerAdded:connect(function(player) repeat wait() until player.Character --Once the player is actually able to play... 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)