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

efficient way of mouse hover on mobile?

hello i already attempted this but i feel like there's a better way and this could lag the players game

code

local mouse = game.Players.LocalPlayer:GetMouse()
local rs = game:GetService("RunService")

while true do
if mouse.Target.Name == "special" then
print"mobile user hovered over something special")
rs.RenderStepped:Wait()
end
end

i also heard using loops was bad is this the best you can do for now?

1 answer

✓ Accepted answer

This is a better way, Enjoy! :)

local mouse = game.Players.LocalPlayer:GetMouse()
local rs = game:GetService("RunService")


rs.Heartbeat:Connect(function()
if mouse.Target.Name == "special" then
print(game.Players.LocalPlayer.Name .."is hovering over something special")
rs.RenderStepped:Wait()
else
print(game.Players.LocalPlayer.Name .."is hovering over".. mouse.Target.Name)
end
end)

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