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

How do I make a ClickDetector add a accessory to a player when they click on it?

Asked by 3 years ago
Edited 3 years ago

local debounce = false

script.Parent.ClickDetector.MouseClick:Connect(function()

01if debounce == false then
02 
03    debounce = true
04 
05 
06 
07    -- I Don't Know What To Put Here
08 
09 
10    debounce = false
11 
12end

end)

0
use instance.new momgggbghghghghg 50 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

ClickDetectors pass in the player that clicks on it as a parameter. You can use it by creating your function with (player) instead of just ()

01local debounce = false
02 
03script.Parent.ClickDetector.MouseClick:Connect(function(player)
04    if not debounce then
05        debounce = true
06        player.Character.Humanoid:AddAccessory(game.ServerStorage.accessory:Clone()) -- clone the accessory or it won't be available to others in the game
07        wait(1)
08        debounce = false
09    end
10end)
0
How would I put the accessory into the code? Or ID? MAD_DENISDAILY2 137 — 3y
0
If you're trying to use an accessory from the catalog, there are several plugins you can use to automatically import catalog items. I personally use one called "EasyInsert" OfficerBrah 494 — 3y
0
I see now MAD_DENISDAILY2 137 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

I would imagine you have your accessories in server storage so:

01local debounce = false
02local accessory = game.ServerStorage.tophat -- this is an example, just put your hat or whatever there
03script.parent.MouseClick:Connect(function()
04    if debounce = false then
05        debounce = true
06        accessory:Clone(game.Players.localplayer.Character)
07        wait(1)
08        debounce = false
09    end
10end)

I'm not a expert on this, but this should work.

0
You’d have to use the Humanoid:AddAccessory() function CrunchChaotic 139 — 3y
0
This won't work. LocalPlayer only exists on LocalScripts, and this should be done in a normal script because you would want everybody on the server to see someone's accessory. Also, Clone doesn't take in any arguments OfficerBrah 494 — 3y

Answer this question