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

How do I make a player wear an accessory when he/she equips a tool?

Asked by 6 years ago

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?

0
By the way, by similar effect I mean to have the accessory on while the tool is equipped. UltraRobloxGuy433 0 — 6y

1 answer

Log in to vote
0
Answered by
wookey12 174
6 years ago
Edited 6 years ago

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

0
fixed it! wookey12 174 — 6y
0
I'm testing it right now, only thing I don't get is line 2(it's a local script yet it's called script.) UltraRobloxGuy433 0 — 6y
0
I'll just try it anyways. UltraRobloxGuy433 0 — 6y
0
i understand your confusion about that. i did too when i began scripting. it doesn't matter what script it is (Module, Local, Script) there is no other word but script to complete a task like that. besides that, how is it working for you? wookey12 174 — 6y
View all comments (5 more)
0
/\ Okay. I'm not that experienced with scripting, thanks. UltraRobloxGuy433 0 — 6y
0
if my script worked correctly, could you click the accept button under this chat please? wookey12 174 — 6y
0
Wait, my pc's internet is broken. The animation cannot load, thus the thing is broken... UltraRobloxGuy433 0 — 6y
0
my script is not working? wookey12 174 — 6y
0
your "Pc's internet" isn't broken if you were able to chat to me. wookey12 174 — 6y
Ad

Answer this question