I'm making a testing area and i wanna make gui buttons that put a hat made out of parts on a player's head, and remove them from the player's head when the button is pressed again. I couldn't really do anything since i'm not a scripter but there's no other website i found.
COMMUNITY QUESTION
How do i make gui buttons that add and remove parts to a player's head?
1 answer
Make the hat, group it, get a character, make it like its on the character's head, delete the character, put the group inside the ReplicatedStorage, name it Hat. Then make the gui, put this script inside the button
local player = script.Parent.Parent.Parent.Parent.Parent
local hat = game.ReplicatedStore:WaitForChild("Hat"):Clone()
script.Parent.MouseButton1Click:Connect(function()
hat.Parent = player.Character.Head
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

8 comments
I did this with a normal script and a local script and it didn't work. The button is there, the hat is inReplicatedStorage.
Oh, sorry, i forgot to tell you that you need an accessory. Click at the plus next to the model's name, and search for Accessory. Press on it, then put everything that is inside the group in the accessory. Get the accessory out of the group, delete the empty group. Name the accessory Hat
I must be doing something wrong. I put a ScreebGui in LocalGui, put a TextButton in that gui and then put the script inside it. The accesory is in ReplicatedStorage.
ScreenGui is in StarterGui, right? Any error codes in the output?
No errors in output.
Hmmm... Then I don't know. Sorry :(
It's okay. I can try something else. (if i find it)
If I may add, I did what you said, and it did clone the hat, but the hat maintained the coordinates of the original part and didn't actually attach to the players head, even though it was grouped to the player.