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

Changing Image with Local Script Error???

Asked by 6 years ago

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

Log in to vote
0
Answered by
piRadians 297 Moderation Voter
6 years ago
Edited 6 years ago

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)

Ad

Answer this question