I'll try to be as specific as I can, please be descriptive if you have an answer for me, thank you! :)

I had created a flying script that has been functioning perfectly smoothly on my game for several months, but after a recent ROBLOX update this month, the character starts to vibrate when I try to fly vertically (Up and down).

This code is in a LOCAL SCRIPT and when you press Q the player flies in the direction the mouse is located on the screen, and it worked as I intended for it to work for a long time until just last week. I have not changed the script at all.

I've toyed with the values for the AngularVelocity and the BodyVelocity numerous times with several different combinations and nothing seems to stop the character from vibrating when the character flies up and down.

You see here that one of my attempts at solving the problem was to change the Vector3 value of AngularVelocity of the Y axis to 2 (Instead of the default 0) and that has not worked.

The issue is NOT that it's in a local script. This code works well online with no issue. My only issue is the vibrating.

Local Script:

Mouse.KeyDown:connect(function(key)
 if key == "q" and not Flying then
	Flying = true
  		local Bv = Instance.new("BodyVelocity",Player.Character.HumanoidRootPart)
 	 		Bv.MaxForce = Vector3.new(6000,6000,6000)
  		local Bav = Instance.new("BodyAngularVelocity",Player.Character.HumanoidRootPart)
			Bav.AngularVelocity = Vector3.new(2,2,0)
			
  		for i = 1,math.huge do wait() 
  			Player.Character.HumanoidRootPart.CFrame = CFrame.new(Player.Character.HumanoidRootPart.Position,Mouse.Hit.p)
			Bv.Velocity = Player.Character.HumanoidRootPart.CFrame.lookVector*40
   		if not Flying then break 
   		end
  	end
 end

14 comments

0

Why are you going up to math.huge. that's kind of unrealistic. Additionally, don't use KeyDown, connect, 2nd Instance.new parent argument. They are deprecated.

0

Use UserInputService or ContextActionService instead, Connect, and parent object as last property when creating.

0

I use math.huge because when the player presses Q again, it stops flying. Also how are they depreciated if its working in game for me already?

0

Could you give me an example of what you mean by the parent object as the last property, thank you!

0

Some stuff that are deprecated still work, it's just not recommend to use because in the future, it could be removed

0

Deprecated items are not removed immediately, but can be removed at any time without warning. If this is to ever happen your scripts could break. UserInputService and ContextActionService are much better ways of handling user input as it's not restricted to the mouse.

0

Ok, thank you for the advice, but do you guys have an answer to my question?

0

And by the parent argument, Instance.new("type", parent). The 'parent' argument is deprecated, and if used improperly caused performance issues. Here's a post that explains this: https://devforum.roblox.com/t/psa-dont-use-instance-new-with-parent-argument/30296

0

Thanks. I removed the depreciated objects and set the Parent of the instances on separate lines and I'm still getting the vibrating.

0

Is there anything else that could be wrong that's still causing the bug?

1

I'd recommend instead of a for loop use RenderStepped.Stepped, or RenderStepped.Heartbeat

0

I'll try that and get back to you, thank you!

3

The second argument of Instance.new() is NOT deprecated! The issue is Parenting it immediately after creating it is only relevant if you're changing some of its values since it'll have to handle both the value that it defaults to and the value you set it to. The issue isn't with Instance.new(), it's parenting before setting values. The link you posted does not mention it being deprecated at all.

2

In this case, it doesn't matter, but don't say its deprecated when it's not.