Hello. So basically, I wanted to make a turret. I made a script, and there seem to be errors. What is the problem? Im... not that experienced with coding. Here is the code:
part = script.Parent
while wait(0.01) do
for i,v in pairs(workspace:GetDescendants()) do
if v.Name == "Humanoid" then
humanoid = v
end
end
if humanoid.Parent == "Finty_james" then
return
end
else
local torso = humanoid.Parent.Torso
local bullet = game.ReplicatedStorage.Bullet
local newBullet = bullet:Clone()
part.Anchored = false
part.Orientation = torso.Orientation
part.Anchored = true
newBullet.Parent = workspace
newBullet.Position = part.Position
newBullet.AssemblyLinearVelocity = Vector3.new(torso.Position)
part.Anchored = false
end
This is my code. Since all the parts couldn't stay in place (Due to the Gravity Property, which I won't be changing,) this is the reason why I used the anchored property 3 times. Also, the Velocity Statement is kinda like a Body Force, but it's a property and can be altered by the Gravity Property of the Workspace Object In Roblox studio.

4 comments
are there error messages?
Yes
Also why I got the humanoid, is because I wanted to make it damage a NPC, but it wouldnt damage me. But I wasnt focusing on that.
Also why I got the humanoid, is because I wanted to make it damage a NPC, but it wouldnt damage me. But I wasnt focusing on that.