local Part = script.Parent --Part to get touched local Tool = ????? --The tool you want to give them local TeamColor = "BrightBlue" --Team color here Part.Touched:connect(function(hit) local Player = game.Players:GetPlayerFromCharacter(hit.Parent) if Player and Player.TeamColor == BrickColor.new(TeamColor) then Tool:Clone().Parent = Player.Backpack Tool:Clone().Parent = Player.StarterGear end end)
Where do I put the tool for it to give it to someone on the same team as the giver is set to? The tool i am trying to give is OCA Nano. Thanks!
First of all, you set the TeamColor to 'BrightBlue' which is not a valid BrickColor, 'Bright blue' however is. Secondly, you would put the location of the tool with the variable Tool.
Here is what the first 3 lines should look like:
local Part = script.Parent -- location of Part local Tool = [Location of Tool] -- An example would be 'game.ReplicatedStorage.Tool' local TeamColor = "Bright blue" -- Lua is case sensitive and spaces matter!
Fix (using debounce):
local Part = script.Parent -- location of Part local Tool = [Location of Tool] local TeamColor = "Bright blue" local debounce = false Part.Touched:connect(function(hit) if debounce == false then local Player = game.Players:GetPlayerFromCharacter(hit.Parent) if Player and Player.TeamColor == BrickColor.new(TeamColor) then Tool:Clone().Parent = Player.Backpack Tool:Clone().Parent = Player.StarterGear end wait(1) -- Wait time until it gives tool again debounce = true end end)