Part is not moving (on the up/down axis), but the position is rapidly changing?

I have an automatic one too which works fine, they are using the same handler and connected the same

I have a gun, and an invisible part to create the bullets from. The part is falling and rising rapidly, making the bullets go farther down.

Yes it is welded, the part it is welded to is not moving either.

No errors.

The position rapidly goes up/down.

game.ReplicatedStorage.Events.Shoot.OnServerEvent:Connect(function(player, MuzzlePos, MousePos)
	if player.Character then
		local sound = player.Character.UpperTorso:FindFirstChild("FireSound")
		
		if sound then
			sound:Play()
		end
		
		local bullet = Instance.new("Part")
		bullet.Shape = Enum.PartType.Cylinder
		bullet.Name = "Bullet"
		bullet.Parent = workspace
		bullet.CanCollide = false
		bullet.Anchored = false
		bullet.Size = Vector3.new(.1, .1, 1)
		bullet.CFrame = CFrame.new(MuzzlePos, MousePos)
		bullet.Material = Enum.Material.Neon
		bullet.BrickColor = BrickColor.new("Cool yellow")
		
		game:GetService("Debris"):AddItem(bullet, 2)
		
		bullet:SetNetworkOwner(player)
		
		local bodyVelo = Instance.new("BodyVelocity")
		bodyVelo.Parent = bullet
		bodyVelo.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
		bodyVelo.Velocity = (bullet.CFrame.LookVector * 200)
		
		bullet.Touched:Connect(function(hit)
			if hit.Parent ~= player.Character then
				bullet:Destroy()
				if hit then
					if hit.Parent:FindFirstChild("Humanoid") then
						hit.Parent:FindFirstChild("Humanoid"):TakeDamage(15)
					end
				end
			end
		end)
	end
end)

1 Like


The video didn’t send idk why.

1 Like

Setting the bullet’s network owner to the player is quite a weird decision. Wouldn’t be very hard to come up with an exploit.

Besides that, it is probably something with your BodyVelocity. Try using smaller values and see what you get.

1 Like

Basically I’m setting the network to the player because the bullet has like a 1 second delay before it moves if you dont

Also I forgot to mention. It’s been doing this while the bullet is anchored and no applied body velocity yet.

Giving network ownership of the bullet to the player allows the player to use exploits to change the position of the bullet and damage players. Again, very easy to abuse.

Ok, can you send your updated script then? The one in the post says the exact opposite.

The -Y speed is clearly from gravity. So what you’ve got is an unanchored part that is falling every frame and picking up speed over time. Something is moving it back up to where it should be each frame, but the velocity is not zero’d out, so it’s still falling.

If it really is welded, then there is some client-server desync in the physics, like the weld is only on the client, but the part is owned and falling on the server, or something along these lines. Otherwise, if it’s not a weld restoring its position every frame, there must be a script doing it. But probably it’s just a weld that doesn’t exist in both contexts.

Heres the old one (I don’t have an updated one):

game.ReplicatedStorage.Events.Shoot.OnServerEvent:Connect(function(player, MuzzlePos, MousePos)
	if player.Character then
		local sound = player.Character.UpperTorso:FindFirstChild("FireSound")
		
		if sound then
			sound:Play()
		end
		
		local bullet = Instance.new("Part")
		bullet.Shape = Enum.PartType.Cylinder
		bullet.Name = "Bullet"
		bullet.Parent = workspace
		bullet.CanCollide = false
		bullet.Anchored = true
		bullet.Size = Vector3.new(.1, .1, 1)
		bullet.CFrame = CFrame.new(MuzzlePos, MousePos)
		bullet.Material = Enum.Material.Neon
		bullet.BrickColor = BrickColor.new("Cool yellow")
		
		game:GetService("Debris"):AddItem(bullet, 2)
		
		bullet:SetNetworkOwner(player)
		
		bullet.Touched:Connect(function(hit)
			if hit.Parent ~= player.Character then
				bullet:Destroy()
				if hit then
					if hit.Parent:FindFirstChild("Humanoid") then
						hit.Parent:FindFirstChild("Humanoid"):TakeDamage(15)
					end
				end
			end
		end)
	end
end)

I don’t understand how that could happen tho.

Sort of like detecting how fast a player is moving from the server, I will check the bullets position rapidly, it should not be changing the left and right axis too much. If its changing it by a wild amount I will kick the player and destroy the bullet.

It can easily happen if you make a weld instance from a client script, so that the weld only exists on the client and the part is just in freefall on the server.

You should probably get access to the updated version then. There may be some error in that code which messes up the physics of your bullet.

The other gun works (its using the same script in serverscriptservice). This would mean it has to be the gun rig then right?

Maybe. Hard to tell without seeing the newest version

The newest code I have is in the first message

Toggle between client and server view when you’re playing, and see what exists where, especially where the welds exist and that they are Active = true.

It could easily be that one gun is getting spawned on the server, but welded up by a client script, where as the other gun model might be in storage with weld instances already created inside it.

image
its on the actual viewmodel for that gun

Okay. Then you have an unanchored bullet with body velocity.

The viewmodel is duplicated from RS to the camera on the local script (so other people cant see your gun obviously). However the viewmodel in RS has the weld on it.