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

RenderStepped or Mouse.Move function?

Asked by
TechModel 118
2 years ago
Edited 2 years ago

Just wanted to know if anyone prefers to use Mouse.Move since it only updates the frames position when the mouse moves, which I prefer this as it wont affect performance. Where renderstepped updates every frame. What are your thoughts? Is it recommended to use renderstepped for some circumstances? Or Move function would lag if the mouse moved mad (real fast)?

local mouse = game.Players.LocalPlayer:GetMouse()
local Frame = script.Parent.Frame

mouse.Move:Connect(function()
    Frame.Position = UDim2.new(0, mouse.x, 0, mouse.Y)
    print(Frame.Position)
end)

or

local mouse = game.Players.LocalPlayer:GetMouse()
local Frame = script.Parent.Frame

game:GetService("RunService").RenderStepped:Connect(function()
    Frame.Position = UDim2.new(0, mouse.x, 0, mouse.Y)
    print(Frame.Position)
end)
0
renderstepped is smoother but honestly your choice, renderstepped is just like usually 60 times a second so basically a wait(0.16) Toastitions 11 — 2y

1 answer

Log in to vote
1
Answered by 2 years ago

Maybe both?

local mouse = game.Players.LocalPlayer:GetMouse()
local Frame = script.Parent.Frame
local rs,debounce=game:GetService("RunService"),false

mouse.Move:Connect(function()
if debounce then return end
debounce=true
    Frame.Position = UDim2.new(0, mouse.x, 0, mouse.Y)
    print(Frame.Position)
rs.RenderStepped:Wait()
debounce=false
end)
Ad

Answer this question