of     1   

AntiFiter
#184323819Thursday, February 25, 2016 11:40 PM GMT

In my gun, I have this bit of code. It makes your gun look up and down. It starts once you equip the gun. local RenderAnimation local function RenderStepped() if Equipped then Character["Right Arm"].LocalTransparencyModifier = 0 Character["Left Arm"].LocalTransparencyModifier = 0 Character.Torso.Neck.C1 = CFrame.new() -- 1 Character.Torso.Neck.C0 = CFrame.new(0, 1.5, 0) * CFrame.Angles(math.asin((LocalMouse.Hit.p - LocalMouse.Origin.p).unit.y), 0, 0) -- 2 else Character["Right Arm"].LocalTransparencyModifier = 1 Character["Left Arm"].LocalTransparencyModifier = 1 RenderAnimation:disconnect() end end RenderAnimation = game:GetService("RunService").RenderStepped:connect(RenderStepped) The lines I marked as 1 and 2 cause just about all of the lag. In Script Performance window, I tested it and just those 2 lines can make it go up to about 3.5%, which is really, really bad. Phantom Forces is far more complex, yet their guns don't lag. Any advice?
AntiFiter
#184324534Thursday, February 25, 2016 11:51 PM GMT

haracter.Torso.Neck.C0 = CFrame.new(0, 1.5, 0) * CFrame.Angles(math.asin((LocalMouse.Hit.p - LocalMouse.Origin.p).unit.y), 0, 0) I got this line from a free model that is something like 2 years old, and I'm guessing Mouse.Y wasn't a thing back then, and is probably much faster. How can I convert it to Mouse.Y, since all of the math it's doing seems to be lagging.
AntiFiter
#184324725Thursday, February 25, 2016 11:54 PM GMT

Actually, Mouse.Y wouldn't work because it's a first person only gun. well there goes that
AntiFiter
#184329584Friday, February 26, 2016 1:02 AM GMT

Bump
AntiFiter
#184333963Friday, February 26, 2016 2:18 AM GMT

Full section* called on equipped local function RenderSteppedLocal() game.Workspace:WaitForChild(Player.Name) local RenderAnimation local function RenderStepped() if Equipped then Character.Torso.Neck.C1 = CFrame.new() -- Character.Torso.Neck.C0 = CFrame.new(0, 1.5, 0) * CFrame.Angles(0, 0, 0) Character.Torso.Neck.C0 = CFrame.new(0, 1.5, 0) * CFrame.Angles(math.asin((Mouse.Hit.p - Mouse.Origin.p).unit.y), 0, 0) Character["Right Arm"].LocalTransparencyModifier = 0 -- May need to remove this. Causes 0.1-0.2% on localscript. Character["Left Arm"].LocalTransparencyModifier = 0 else Character["Right Arm"].LocalTransparencyModifier = 1 Character["Left Arm"].LocalTransparencyModifier = 1 RenderAnimation:disconnect() end end RenderAnimation = game:GetService("RunService").RenderStepped:connect(RenderStepped) end
AntiFiter
#184406851Saturday, February 27, 2016 4:29 PM GMT

Should I be worried about it getting up to 3.5%? The wiki says so, but sometimes it doesn't always mean it's laggy.
71428
#184407549Saturday, February 27, 2016 4:42 PM GMT

RenderStepped is currently acting up for me too.
AntiFiter
#184407918Saturday, February 27, 2016 4:49 PM GMT

Was it not before? Just a few days ago was the first time I ever checked the script performance window for it.
71428
#184407987Saturday, February 27, 2016 4:51 PM GMT

Well I don't know for you but for me there's definitely been a change with the RenderStepped. I can feel it in my bones.
AntiFiter
#184482365Sunday, February 28, 2016 5:36 PM GMT

b
AntiFiter
#184549130Monday, February 29, 2016 9:23 PM GMT

b2
Born2Script
#184550171Monday, February 29, 2016 9:44 PM GMT

Instead of renderstepped, try using mouse.Move
AntiFiter
#184556565Monday, February 29, 2016 11:34 PM GMT

No.
Darkmist101
#184556956Monday, February 29, 2016 11:40 PM GMT

If you are constantly using the same CFrames, you should make them a variable. That way you don't need to create one every 1/60 of a second (approx). As well, you can try to make the math functions local. Is there a reason you need to set constantly the Neck.C1? I wouldn't think so. In fact, a lot of what you are doing is resetting properties that should be static. That's all I can see anyways.
AntiFiter
#184806831Saturday, March 05, 2016 7:27 PM GMT

"If you are constantly using the same CFrames, you should make them a variable. That way you don't need to create one every 1/60 of a second (approx)." I could do that, but still, if you're moving around it won't make a difference. "As well, you can try to make the math functions local." I tried making Asin a variable, but it didn't help too much. "Is there a reason you need to set constantly the Neck.C1? I wouldn't think so. In fact, a lot of what you are doing is resetting properties that should be static." It glitches the head if you don't. I'll try to make it work without it though.
LongKillKreations
#184808584Saturday, March 05, 2016 7:54 PM GMT

This isn't really a fix but you can try to squeeze performance out of the program local cf = CFrame.new local angles = CFrame.Angles local asin = math.asin local c1Default = cf() local c0Default = cf(0, 1.5, 0) -- set variables for the neck and left/right arm neck.C1 = c1Default neck.C0 = c0Default * angles(asin((LocalMouse.Hit.p - LocalMouse.Origin.p).unit.y), 0, 0)

    of     1