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)
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)