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

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

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)

2 comments

0

umm lol it's on line 19 it must be end) to close line 3

0

Ok, thx!

1 answer

✓ Accepted answer

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)

3 comments

0

Oops, I accidentaly forgot to include that this is a GUI, I'm sorry!

0

Oh, and thanks for replying quickly!

0

I re-read your code. You forgot to put an end) at line 10, and at line 19 it should be end)

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