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

i am trying to make a sniper when i zoom in its not stable how do i fix?

zoom script model that i Made : https://www.roblox.com/catalog/02521288629/redirect

script.Parent.Equipped:Connect(function()
	local plr = game.Players.LocalPlayer
	local mouse = plr:GetMouse()
	local char = game.Players.LocalPlayer.Character
	local zomm = true
	local cam = game.Workspace.CurrentCamera
 mouse.Button2Down:Connect(function()
	
while zomm == true do
	wait()
	cam.CameraType = Enum.CameraType.Scriptable
	cam.CFrame = script.Parent.zoomin.CFrame
end
end)
	 mouse.Button2Up:Connect(function()
		zomm = false
		cam.CameraType = Enum.CameraType.Custom
		wait(2)
		zomm = true
		
	end)
	
end)

1 answer

✓ Accepted answer

your setting the camera's CFrame (coordinate frame) and using a loop using wait() as a yield

A simpler way to do it is setting the camera subject to zoomin, and lock the player's camera to FirstPerson mode

Script would look like this:

script.Parent.Equipped:Connect(function()
	local plr = game.Players.LocalPlayer
	local mouse = plr:GetMouse()
	local char = game.Players.LocalPlayer.Character
	local zomm = true
	local cam = game.Workspace.CurrentCamera
	mouse.Button2Down:Connect(function()
		if zoom then
			cam.CameraSubject = script.Parent.zoomin -- sets camera subject to the scope
			plr.CameraMode = Enum.CameraMode.LockFirstPerson -- sets player’s camera to first person
		end
	end)
	mouse.Button2Up:Connect(function()
		zomm = false
		cam.CameraSubject = char:FindFirstChildOfClass(“Humanoid”) -- or change to your humanoid’s name
		plr.CameraMode = Enum.CameraMode.Classic -- makes player able to go into third person
		wait(2)
		zomm = true
	end)
end)

tell me if it worked or not!

3 comments

0

you could also lower the FOV of the camera, but that might not be the effect you want

0

it work but when i move it washables

0

washables?

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