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

Can someone fix my aim down sights script?

Asked by 10 years ago

I'm trying to make a script that will keep the a gun at the right angle and position so that you can look down the barrel, here is what I've got. I'm a new scripter and the multiplications took me a long time to figure out. If there is an easier way please tell me.

camerapos = game.Workspace.CurrentCamera.CoordinateFrame.y
print(game.Workspace.CurrentCamera.CoordinateFrame.y)
while true do
wait()
if camerapos > 4.121 and camerapos < 4.896 then ---- I think the problem is that this line isn't true even though it should be
multiby = camerapos -4 --Gives a value between 0.121 and 0.896 ()
multiby = multiby * 1.29032258065 -- turns that into a value between 0 and 1, depending on how high or low you are looking
addto = multiby * 3.5 -- 3.5 is the difference between gun facing almost directly up and almost directly down. (0,-0.05,0)- Is down and (0, 3, 0) is up
script.Parent.GripForward = Vector3.new(script.Parent.GripForward.x, -0.5 + addto, script.Parent.GripForward.z)--when y is -0.5 it looks correct when the camera.y is at 4.121 and when y is 3 it looks correct when your camera y is at --4.8
end
end

The gun keeps pointing down, i think it works for a while then it just breaks or something. I hope someone can help. I hope some day when I get better, I can give back to the community by helping others.

Answer this question