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

Parts Body Velocity is not moving the part?

I just picked up learning to script so this may be a really stupid mistake. I'm trying to make a really janky gun to test my current skill with scripting, and I have been staring at this for almost a week now and I cant see what wrong with it. (Also, let me know if I formatted this post wrong)

Gun_Fired.OnServerEvent:Connect(function(player, Mouse_lookVector)
	local Bullet = BT:Clone()
	Bullet.Parent = game.Workspace
	Bullet.Name = "Bullet"
	Bullet.Position = gun.Handle.Position
	
	local BV = Instance.new("BodyVelocity", Bullet)
	BV.Velocity = Vector3.new(Mouse_lookVector) * 10
	print(Mouse_lookVector)
	
end)

The strange thing is, The body velocity is in the Bullet, and the "Velocity" property of body velocity is also being set correctly, and yet the part does not move at all, I am simply perplexed as to what I'm doing wrong. Once again, bear with me if this is a stupid mistake, as I have only very recently started scripting.

1 comment

0

might be a dumb response but i see you're cloning it. could the clone be anchored? add Bullet.Anchored = false and it might be worth offsetting the positioning when you spawn the clone from your gun something like +Vector3.new(0,0,5)

1 answer

✓ Accepted answer

It seems to me like you're trying to create a vector3 from another vector3. It should be just

BV.Velocity = Mouse_lookVector * 10

If you want to use the current set up you have you can use varadic arguments to do this you add ... to your code so it would look like this:

Gun_Fired.OnServerEvent:Connect(function(player,...)

and then to create the new vector you simply do

Vector3.new(...)

Also keep in mind that you would need to send 3 numbers for the x,y, and z coordinates.

You can also read more about varadic arguments since my explaination of them is really the bare minimum.

https://developer.roblox.com/en-us/articles/Variadic-Functions

1 comment

0

Thanks, the problem was that, and the part was anchored, and after fixing both, the bullet is working as intended.

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