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 8 years ago
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

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

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!

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

Answer this question