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

?I have a script that I found off of a youtube tutorial. I want to know how it works.

So I have an aim UserInputService thingy, but I have almost no idea how it works!

UIS.InputBegan:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton2 and equipped then
		if (Camera.CoordinateFrame.p - game.Players.LocalPlayer.Character.Head.Position).magnitude < 1 then
			zooming = true
			UIS.MouseDeltaSensitivity = 90/originalView
			for i = 1, 60 do
				if zooming == false then break end
				Camera.FieldOfView = Camera.FieldOfView + (45 - Camera.FieldOfView) * (i / 60)
				RunServ.RenderStepped:wait()
			end

			zooming = false
	end	end
end)


local inputend = UIS.InputEnded:Connect(function (input, GameHandledEvent)
	if not equipped  then return end
	if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
		Firing = false
	elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
		zooming = false
		UIS.MouseDeltaSensitivity = 1
		for i = 1, 60 do
			if zooming == true then break end
			Camera.FieldOfView = Camera.FieldOfView + (originalView - Camera.FieldOfView) * (i / 60)
			RunServ.RenderStepped:wait()
		end
	end
end)

I just want an explanation of how it works. I understand keybind functions and all that, but I don't know how the script knows if you're still holding down the mouse. Any ideas? Please note that this script works perfectly and that there are no errors.

1 answer

✓ Accepted answer

Its straightforward, InputBEGAN and InputENDED. Think of it like KeyDOWN and KeyUP

1 comment

0

Oh wait, I see. Lol thanks.

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