I’ve ran into this issue where my robot isnt firing at me properly, i’ve been at this for 2 days.
Code:
function Attack(target)
local Bullet = game.ReplicatedStorage.Enemys.Tesla.OBJECTS.Bullet:Clone()
Bullet.Parent = workspace
Bullet.Position = script.Parent.HumanoidRootPart.Position + Vector3.new(0,3,0)
local BV = Instance.new("BodyVelocity",Bullet)
BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BV.Velocity = Bullet.CFrame.LookVector * 100
script.Parent["Small laser shoot 4"]:Play()
Bullet.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
if hit.Parent.Name == "Cargo" then
hit.Parent.Humanoid:TakeDamage(50)
Bullet:Destroy()
else if hit.Parent:FindFirstChild('enemy') then
else
hit.Parent.Humanoid:TakeDamage(20)
Bullet:Destroy()
local L = script.Parent.FrontPlates.Sparks:Clone()
L.Parent = hit.Parent.HumanoidRootPart
L:Emit(5)
hit.Parent.Humanoid.WalkSpeed = hit.Parent.Humanoid.WalkSpeed - 5
wait(0.5)
hit.Parent.Humanoid.WalkSpeed = hit.Parent.Humanoid.WalkSpeed + 5
L:Destroy()
end
end
end
end)
end