I am making one minigun and I dont use “Instance.new(Part, game.Workspace)” I am just cloning from the RS(ReplicatedStorage) into the Workspace.
something like this:
Local script
--part of script--
[...]
GunShooting = mouse.Button1Down:Connect(function()
shooting = true
while shooting do
wait(0.15)
RE:FireServer(tool.ToolsParts.BulletLocation.Position, tool.ToolsParts.BulletLocation.Orientation, mouse.Hit.p)
gunFire:Play()
shootingAnimation:Play()
mouse.Button1Up:Connect(function()
shooting = false
shootingAnimation:Stop()
GunShooting = nil
end)
end
end)
end)
On Server side
local RS = game:GetService("ReplicatedStorage")
local RE = RS.CandyCaneMinigun
RE.OnServerEvent:Connect(function(player, gunPos, gunOr, mosPos)
local bullet = game.ReplicatedStorage.CandyCane:Clone()
bullet.Parent = game.Workspace
bullet.Position = gunPos
local distance = (mosPos - gunPos).magnitude
local speed = 350
bullet.CFrame = CFrame.new(gunPos, mosPos)
bullet.Velocity = bullet.CFrame.lookVector * speed
local fly = Instance.new("BodyForce",bullet)
fly.Force = Vector3.new(0, 0, 0)
bullet.Orientation = gunOr + Vector3.new(0, -180, 0)
local attacker = Instance.new("StringValue")
attacker.Name = "Attacker"
attacker.Parent = bullet
attacker.Value = player.Name
end)
It works fine the problem is I dont know why I get this erros…
how it works:
I will use Raycasting after I am just making some tests