I have a tool named Pistol, and when equipped, it will check what team he/she(the player) is in. Suppose there are two teams, say, Red and Blue. If the script detects the player is in: Red - The player will be given the Comedy Accessory. Blue - The player will be given the Tragedy Accessory.
I think it uses the onEquip and onUnequip functions, onEquip because I want the script to detect when the tool is equipped, onUnequip because I want the accessory to be taken off when unequipped.
If this isn't possible, is there any other way I can do this with a similar effect?
hey man, hope this helps. i don't usually help people like this, but if this helped, please accept my answer.
wait(1) local Pistol = script.Parent --i think this script is in the tool, right? if not change it to where the pistol is. local player = game.Players.LocalPlayer local character = player.Character Pistol.Equipped:connect(function() local Comedy = game.ServerStorage.ComedyAccessory:Clone() --make sure to parent the accessory into server storage, and name it 'ComedyAccessory' local Tragedy = game.ServerStorage.TragedyAccessory:Clone() --do the same steps as the other accessory if player.TeamColor == BrickColor.new('Bright red') then --change the teamColor exactly to the teamcolor you chose Comedy.Parent = player.Character end if player.TeamColor == BrickColor.new("Bright blue") then --change the teamColor exactly to the teamcolor you chose Tragedy.Parent = player.Character end Pistol.Unequipped:connect(function() if player.TeamColor == BrickColor.new("Bright red") then --change the teamColor exactly to the teamcolor you chose Comedy:Destroy() end if player.TeamColor == BrickColor.new("Bright blue") then --change the teamColor exactly to the teamcolor you chose Tragedy:Destroy() end end) end)
MAKE SURE THIS IS IN A LOCALSCRIPT PARENTED INSIDE OF THE PISTOL