Local scripts don’t work in the workspace, so you might not want to do that. I can’t really tell what the issue is with the server one because we don’t know which parts of the rig you’re referring to or what you’re trying to accomplish, what is Sight? Could you provide screenshots?
I have moved the touched event to the server script it was firing to
local fire = script.Fire
fire = script.Parent.Humanoid.Animator:LoadAnimation(fire)
local MeshId = "rbxassetid://2837888103"
local D = game:GetService("Debris")
local Hit
local canShoot = false
local Sight = script.Parent.Sight
local SeeingTarget = false
function Shoot()
local bullet = script.Bullet:Clone()
bullet.Parent = workspace
bullet.Transparency = 0
bullet.Position = script.Parent["M4A1 Model"].BarrelCover.Attachment.WorldPosition
bullet.Orientation = Vector3.new(math.random(1, 360), math.random(1, 360))
bullet.AssemblyLinearVelocity = Vector3.new(10, 10, 2)
bullet.AssemblyLinearVelocity = Vector3.new(10, -10, 2)
D:AddItem(bullet, 5)
fire:Play()
wait(.1)
bullet.AssemblyLinearVelocity = Vector3.zero
task.wait(0.05)
local Part = script.Part:Clone()
game:GetService("Debris"):AddItem(Part, 10)
Part.Parent = workspace
Part.Transparency = 0
Part.Position = script.Parent["M4A1 Model"].BarrelCover.Attachment.WorldPosition
Part.Orientation = Vector3.new(0, 0, 0)
local Attachment = Instance.new("Attachment", Part) -- the attachment used in Linearvelocity
local LV = Instance.new("LinearVelocity", Attachment) -- creating the linear velocity
LV.MaxForce = math.huge -- no need to worry about this
LV.VectorVelocity = script.Parent.HumanoidRootPart.CFrame.lookVector * 100 -- change 100 with how fast you want the projectile to go
LV.Attachment0 = Attachment-- setting the attachment
script.Part.Script:Clone().Parent = Part
task.wait(.2)
end
Sight.Touched:Connect(function(Part)
seeingTarget = true
end)
Sight.TouchEnded:Connect(function()
seeingTarget = false
end)
while SeeingTarget == true do
Shoot()
end