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

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

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

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

2 comments

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.

0

So that is why i put the "else" So that you can paste your code there

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