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

Why won't hat button in GUI make hat stay on player?

Asked by 5 years ago

Hi there, I am still working on a player customizer GUI, and I made a hat GUI for it. Well, it was all working perfectly until I can't remember what happened. It does work, yes, but not how I want it. You see, when you press a button, the hat goes on the player, but then disappears. Here's the script:

01Player = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent
02Human = Player.Character
03 
04debounce = true
05 
06function onClicked(mouse)
07 
08if debounce == true then
09    debounce = false
10    Hat = Instance.new("Accessory")
11    Handle = Instance.new("Part")
12    Hat.Name = "Hatino"
13    Handle.Name = "Handle"
14    Handle.Parent = Hat
15    Handle.Position = Human:findFirstChild("Head").Position
View all 31 lines...

Keep in mind that it is in StarterGUI and that it does work but disappears the next second. It's also in a normal script, not local, but I tried making it in local and had the same outcome.

Thank you!

0
First want to mention that the script.Parent.Parent..... can easily be replaced with game.Players.LocalPlayer if you're using a Localscript, however can you try Humanoid:AddAccessory instead of setting the attachment manually? User#834 0 — 5y
0
Instead of parenting the hat to human, try parenting the hat to "humanoid" Oh. And you need to have a game:getservice("Players") ffancyaxax12 181 — 5y
0
Thanks guys, I'll try this out! PadmeOragana 78 — 5y
0
Hi, I tried the "game.Players.LocalPlayer" but it didn't work, the hat didn't even show. PadmeOragana 78 — 5y

Answer this question