I have a gun script where the gun fires bullets from a FirePart inside the tool, but when I equip the tool before everything is fully loaded, the animation seems to be playing properly but the script can’t get the FirePart.Positon properly, when I look inside the studio I see the part is actually placed where it should be (Y level above 0), but when running print(Part.Position)
the Y level is under 0, the position seems to return wrong only at the first bullet fired from the gun
As you can see, the hit marker only appears when I hold the gun (The 2nd bullet), but the first one doesn’t make any hits.
Fire = function()
Config.Ammo = Config.Ammo - 1
-- // Fire bullet
local Bullets = {}
for i = 1, Config.HitsPerFire do
table.insert(Bullets, {BulletController:Fire(CFrame.new(Config.FirePart.Position, Mouse.Hit.Position), Cache)})
end
spawn(function()
pcall(Config.Animations["Fire"], Tool, Animator, Camera, UI)
end)
Recoil()
end
Mouse.Button1Down:Connect(function()
if Equipped then
pcall(function() UI.Visible = true end)
Firing = true
for i = 1, Config.FiresPerHold do
if (Config.Ammo <= 0) or Config.Reloading then
break
end
Fire()
wait(1 / (Config.RPM / 60))
pcall(refreshUI)
if not Firing then break end
end
Firing = false
end
end)