Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How come my gui button won't take off a limb when pressed? Help please

script.Parent.MouseButton1Click:connect(function()
	local Player = script.Parent.Parent.Parent.Parent.Parent
	local g = Player.Character
	local leg = g:FindFirstChild('Right Leg')
	leg:Destroy()
end)

This is in a Gui called Riddle and in a GUI called Riddles and in StarterGui I am trying to make it so when clicked it takes off the left leg. For some reason it is not working at all please help

1 answer

✓ Accepted answer

Hi there!

script.Parent.MouseButton1Down:connect(f­unction()
local Player = script.Parent.Parent.Parent.Parent.Parent
        local darm = Player.Character:FindFirstChild('Left Leg')
        darm:Destroy() --You should use the :Destroy() instead of :remove(). Remove is disambiguate.
**end**

You're using an anonymous function and haven't closed the end properly, you should close it like end) instead of end.

http://wiki.roblox.com/index.php?title=Anonymous_function

Hope this helped!

5 comments

0

t edited my question because I noticed it was in a different GUI. Can you still fix it?

0

Try changing :FindFirstChild to :WaitForChild, make the script a local script and change local Player = script.Parent.Parent.Parent.Parent to local Player = game.Players.LocalPlayer

0

Alright ill try that

0

Can I add you?

0

I accepted your friend request.

This discussion is preserved as it was. New answers, comments, and votes are closed.