I have a part (gun) in the player's camera. But when I tried to set the bullet's position to the pistol's position, I noticed that the pistol's X and Z coordinates are alright, but the Y continuously changes. So if I Clone the bullet to the pistol's barrel, it spawns underground, where the barrel's coordinates are, but the pistol is still normal in the player's view.

print(weapon.Barrel.Position.Y)

Output: (every second)

3.6052224636078
2.7897069454193
2.0458738803864
0.38624891638756
-1.7365729808807
-2.2422847747803
...

This is how I welded the gun to the camera:

weap.Parent = vchar;
vchar.Parent = camera;

local jo = Instance.new("Motor6D");
jo.C0 = CFrame.new(2, -1.5, -3.5);
jo.Part0 = vchar.Head;
jo.Part1 = weap.Handle;
jo.Parent = vchar.Head;

It looks like it's slowly falling down, but it's still visible in the player's view normally. Any ideas why it does this, or how can I get the real Y coordinates?

(Edit: I made a picture of what happens. You can see that the parts are in the camera, and they are visible and selected, but the Move Tool shows them underground, and the output shows the Y coordinates. I don't understand what's happening)

2 comments

0

Maybe the bullet is unanchored?

0

It is. But i can't shoot or move it if I anchor it. Plus I don't think that has anything to do with the weapon's Y coordinates changing