Hello I tried a script today for my game a mute button but the image is not changing and in the output is then some Error did I write something wrong?
script.Parent.MouseEnter:Connect(function() while true do script.Parent:TweenPosition(UDim2.new(0.041, 0,0.106, 0)) wait(1) script.Parent:TweenPosition(UDim2.new(0.038, 0,0.106, 0)) end end) script.Parent.MouseButton1Click:Connect(function() print("de") script.Parent.Image = "rbxassetid://176572749" end)
MouseEnter
is NOT an Event of ClickDetector
, it is anGuiObject
Event.
Instead, use MouseHoverEnter
(for when the mouse enters) and MouseHoverLeave
(for when the mouse leaves).
Your code would be this:
script.Parent.MouseHoverEnter:Connect(function() while true do script.Parent:TweenPosition(UDim2.new(0.041, 0,0.106, 0)) wait(1) script.Parent:TweenPosition(UDim2.new(0.038, 0,0.106, 0)) end end) script.Parent.MouseButton1Click:Connect(function() print("de") script.Parent.Image = "rbxassetid://176572749" end)