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

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

Asked by 9 years ago
1script.Parent.MouseButton1Click:connect(function()
2    local Player = script.Parent.Parent.Parent.Parent.Parent
3    local g = Player.Character
4    local leg = g:FindFirstChild('Right Leg')
5    leg:Destroy()
6end)

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

Log in to vote
1
Answered by
0_0 70
9 years ago

Hi there!

1script.Parent.MouseButton1Down:connect(f­unction()
2local Player = script.Parent.Parent.Parent.Parent.Parent
3        local darm = Player.Character:FindFirstChild('Left Leg')
4        darm:Destroy() --You should use the :Destroy() instead of :remove(). Remove is disambiguate.
5**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!

0
t edited my question because I noticed it was in a different GUI. Can you still fix it? duckyo011 36 — 9y
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_0 70 — 9y
0
Alright ill try that duckyo011 36 — 9y
0
Can I add you? duckyo011 36 — 9y
0
I accepted your friend request. 0_0 70 — 9y
Ad

Answer this question