So, I've been workin' on on this GUI that removes the morph named "Chest" from player's character. It works, but when I click the remove button 2 times, and then morph again, the remove wont work anymore. I tried to fix, but there's an error in the script. :c
wait(1) player = game:GetService("Players").LocalPlayer gui = script.Parent button = gui.Button button.MouseButton1Down:connect(function() local found = player.Character:findFirstChild("Chest") if found then end end found:Destroy() player.Character.Humanoid.MaxHealth = 100 wait(0.1) end
thank thee
Please tab your code correctly.
So what's the point of that if statement on line 08? It's basically saying, "if found exists then do nothing" Also, the end on line 10 should be removed, because it is not needed. You have an if statement and a function, so you only need two ends. The final end, on line 14, should have a )
around it, to close the connect() method. The wait() on line 13 is not really needed either.
Here's how it should be fixed:
wait(1) player = game:GetService("Players").LocalPlayer gui = script.Parent button = gui.Button button.MouseButton1Down:connect(function() local found = player.Character:findFirstChild("Chest") if found then found:Destroy() player.Character.Humanoid.MaxHealth = 100 end end)