alecspw
(ThatAlecs)
August 17, 2022, 9:53am
#1
Hello everyone, I’m trying to make a button that when pressed removes your hats/accessories, and this is the code:
script.Parent.MouseButton1Click:Connect(function()
game.PlayerAdded:Connect(function(player)
player.CharacterAppearanceLoaded:Wait()
player.Character.Humanoid:RemoveAccessories()
end)
end)
And this is where it’s placed (ScreenGUI)
Still learning how to script those type of stuff but hopefully I’ll learn something from this.
How can I fix this?
Thanks in advance!
Also, you don’t need to hook this on an event, since it will not work. Just directly use player.CharacterAppearanceLoaded:Wait() player.Character.Humanoid:RemoveAccessories()
alecspw
(ThatAlecs)
August 17, 2022, 9:58am
#4
Just like this? I need it hooked to the button
script.Parent.MouseButton1Click:Connect(function()
player.CharacterAppearanceLoaded:Wait()
player.Character.Humanoid:RemoveAccessories()
end)
Yes, just like that. The .PlayerAdded event will wait until a new Player joins the game, not immediately removing the accessories.
msix29
(msix29)
August 17, 2022, 9:59am
#6
It needs to be game.Players.PlayerAdded
alecspw
(ThatAlecs)
August 17, 2022, 10:01am
#7
This is the error it gives me.
game.Players.PlayerAdded.MouseButton1Click:Connect(function()
player.CharacterAppearanceLoaded:Wait()
player.Character.Humanoid:RemoveAccessories()
end)
msix29
(msix29)
August 17, 2022, 10:02am
#8
Not like this, it should be…
script.Parent.MouseButton1Click:Connect(function()
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAppearanceLoaded:Wait()
player.Character.Humanoid:RemoveAccessories()
end)
end)
alecspw
(ThatAlecs)
August 17, 2022, 10:03am
#10
Doesn’t give any errors, but when I click tbe button it doesn’t do anything
msix29
(msix29)
August 17, 2022, 10:04am
#11
It will wait until a player joins, what do you exactly want to do here?
alecspw
(ThatAlecs)
August 17, 2022, 10:05am
#12
When the player clicks a TextButton, the player hats get removed, sort of like a hat remover part but in a gui
msix29
(msix29)
August 17, 2022, 10:06am
#13
Try this
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
player.CharacterAppearanceLoaded:Wait()
player.Character.Humanoid:RemoveAccessories()
end)
alecspw
(ThatAlecs)
August 17, 2022, 10:13am
#15
I’ve put
script.Parent.MouseButton1Down:Connect(function ()
game.ReplicatedStorage.RemoteEvent:FireServer()
end)
as a LocalScript in the textbutton,
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function (player)
player.CharacterAppearanceLoaded:Wait()
player.Character.Humanoid:RemoveAccessories()
end
in serverscriptserver,
and a remoteevent in replicatedstorage,
but still no errors in the console nor the button works
msix29
(msix29)
August 17, 2022, 10:13am
#16
Did you try the script I gave you?
alecspw
(ThatAlecs)
August 17, 2022, 10:14am
#18
I did, it does the same thing, ive put that as a localscript in the text button, still no errors in the console tho
1 Like
MahDev0
(MahDev)
August 17, 2022, 10:21am
#19
Just test this hope this helped
script.Parent.MouseButton1Click:Connect(function()
game.Players.LocalPlayer.Character.Humanoid:RemoveAccessories()
end)
alecspw
(ThatAlecs)
August 17, 2022, 10:26am
#22
It makes me spawn with no hats, but then they come back after a few seconds
I edited the script. (char limit bruh)