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

How would I only run a .RenderStepped when the player is not rotating their camera?

Asked by
nanaluk01 247 Moderation Voter
6 years ago

How would I only run a .RenderStepped when the player is not rotating their camera with their right mouse button?

I know this is not a request-site, but I have no idea how I would do this.

I currently have a lot of code inside a .RenderStepped function, but I have noticed that when I rotate my camera with my right mouse button, there is a MASSIVE amount of lag. I want to fix this, but I have no idea how.

I am thinking something like this would work

game:GetService("RunService").RenderStepped:Connect(function()

    -- Check if the player is rorating their camera with the right mouse button

        -- Do stuff
end)

Any help is greatly appreciated!

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Remember to use Button2Down for right click

local mouse = game:GetService("Players").LocalPlayer:GetMouse()
game:GetService("RunService").RenderStepped:Connect(function()
    if mouse.Button2Down then
        -- Do nothing
    else
        -- your script
    end
end)

Try this

0
What I mean is that the code inside the .RenderStepped function will only run if I am NOT currently rotating my camera with the right mouse button. nanaluk01 247 — 6y
0
So that is why i put the "else" So that you can paste your code there greatneil80 2647 — 6y
Ad

Answer this question