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

Changing Image with Local Script Error???

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)

1 answer

✓ Accepted answer

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)

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