Gun doesn’t work properly if cloned into player’s backpack, but works if player picks up the gun, it works perfectly fine.
I have no clue how to mitigate the issue.
me using a quick button i made to clone a rifle to my backpack; then it proceeding to break
https://i.gyazo.com/f16f400db7ed3f39e8e4b1017462d03a.mp4
a snippet of the server script i use.
local replicatedStorage = game:GetService("ReplicatedStorage")
local fireGunEvent = replicatedStorage.FireGun
local reloadingSFXevent = replicatedStorage.ReloadingSFX
fireGunEvent.OnServerEvent:Connect(function(player, rifle, startPos, endPos)
local gunshotSFX = rifle.Handle.GunShot
local reloadSFX = rifle.Handle.Reload
local particles = rifle.Barrels.MuzzleFX:GetChildren()
local headShotDamage = rifle:GetAttribute("HeadshotDamage")
local MaxDistance = rifle:GetAttribute("MaxDistance")
local Damage = rifle:GetAttribute("Damage")
local direction = (endPos - startPos).Unit * MaxDistance
local raycastRes = game.Workspace:Raycast(startPos, direction)
gunshotSFX:Play()
for i, particles in ipairs(particles) do
task.spawn(function()
particles:Emit()
end)
end