Mouse not changing when hovering over a TextButton

So I made a simple script that when you hover over ANY gui button, it makes a cursor follow your mouse. Heres the script: (the cursor that is supposed to show isn’t showing but the other one is)

run.RenderStepped:Connect(function()
	imgToShow.Position = UDim2.fromOffset(uis:GetMouseLocation().X, uis:GetMouseLocation().Y - 1)

	local ui = plrUi:GetGuiObjectsAtPosition(UDim2.fromOffset(uis:GetMouseLocation().X, uis:GetMouseLocation().Y -1 ))

	for _, v in pairs(ui) do
		if v:IsA('GuiButton') then
			script.Parent:WaitForChild('cursor').Visible = false
			script.Parent:WaitForChild('link').Visible = true

			imgToShow = script.Parent:WaitForChild('link')
		else
			script.Parent:WaitForChild('cursor').Visible = true
			script.Parent:WaitForChild('link').Visible = false

			imgToShow = script.Parent:WaitForChild('cursor')
		end
	end
end)

Why not just use

GuiObject.MouseEnter:Connect(function()--// Or use MouseEntered I can't access RS rn

end)

Because in my game theres gonna be alot of GuiButtons, and it seems excessive to do that for every button.

Well I am not experienced with RunService that much but try this

for index,guiObject in pairs(script.Parent["WhereEverTheParentIsWithTheButtons"]:GetChildren()) do
    gui.Object.MouseEnter:Connect(function()

    end)
end

Oh true I can just do that. eeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

Wait actually I don’t think so. Because you’ll have to use Instance:GetDescendants and it’ll be laggy. That could work but it could get laggy.

I mean is their a button inside of the button?

I mean like this for e.g. lets say a frame named “Bob” has 20 buttons in it and inside the buttons is nothing just do this

for i,v in pairs(script.Parent.Bob:GetChildren()) do
    print(v.Name) --// Gets the name of the buttons
end

No but I keep buttons inside of Frames. (I’m making kinda like an operating system game and I put the ppas in a frame)

Oh okay I’ll do that. Thanks i just thought about it

1 Like