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

Why doesn't my table of click detectors work?

Asked by 2 years ago

Hello. I'm trying to make a script that changes the ClickDetector's mouse icon when the player hovers on a part that can be clicked, and when they stop hovering on it, it changes back to default.

However, it doesn't work with a table, and I have no idea on how to fix it because I don't really use tables that often.

task.defer(function()
local mouse = game.Players.LocalPlayer:GetMouse()
    mouse.Icon = 'http://www.roblox.com/asset/?id=9824394203'

    local clickDetector = {game.Workspace.Part.ClickDetector, game.Workspace.Part2.ClickDetector}

    clickDetector.MouseHoverEnter:Connect(function()
        mouse.Icon = 'http://www.roblox.com/asset/?id=4595124035'
        print("Cursor Changed!")
    end)

    clickDetector.MouseHoverLeave:Connect(function()
        mouse.Icon = 'http://www.roblox.com/asset/?id=9824394203'
        print("Default Cursor.")
    end)

end)

The error: attempt to index nil with 'Connect'

Answer this question