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

Why is the "Parent" underlined red? (Solved)

Asked by 4 years ago
Edited 4 years ago

Why is the "Parent" in the third block underlined red? (It isn't underlined in scriptinghelpers)

local Parent = script.Parent

Parent.MouseEnter:Connect(function(x, y)
    Parent.Position = UDim2.new(0, 0, 0.5, 0)

    wait()

    Parent:TweenPosition(UDim2.new(0.05, 0, 0.5, 0))
    Parent.WooshSound:Play()

Parent.MouseLeave:Connect(function(x, y)
    Parent.Position = UDim2.new(0, 0, 0.5, 0)

    wait()

    Parent:TweenPosition(UDim2.new(0.5, 0, 0.5, 0))
    Parent.WooshSound:Play()

end

Parent.MouseButton1Click:Connect(function()
    Parent.Image = "rbxgameasset://Images/SoundIconClicked"
    Parent.ClickSound:Play()
    wait()
    Parent.Image = "rbxgameasset://Images/SoundIcon"
end)
0
umm lol it's on line 19 it must be end) to close line 3 Mr_m12Ck53 105 — 4y
0
Ok, thx! Abysmallow 1 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

MouseButton1Click is not a property of a clickdetector.

You'll need to use .MouseClick for a left click, or .RightMouseClick for a right click.

https://developer.roblox.com/en-us/api-reference/class/ClickDetector https://developer.roblox.com/en-us/api-reference/event/ClickDetector/MouseClick

So, your fixed function looks like this:

Parent.MouseClick:Connect(function()
       Parent.Image = "rbxgameasset://Images/SoundIconClicked"
       Parent.ClickSound:Play()
       wait()
       Parent.Image = "rbxgameasset://Images/SoundIcon"
end)
0
Oops, I accidentaly forgot to include that this is a GUI, I'm sorry! Abysmallow 1 — 4y
0
Oh, and thanks for replying quickly! Abysmallow 1 — 4y
0
I re-read your code. You forgot to put an end) at line 10, and at line 19 it should be end) MakeYourEscape 334 — 4y
Ad

Answer this question