Turret Not Firing Missile

I’m using a free model turret from December 2017 that doesn’t work anymore. The turret WORKS and all with aiming and stuff, but the missile doesn’t fire, it just sits there at the CFrame the player was aiming at. I can’t provide any clips due to the website saying there’s issues going on when attempting to upload, so I’ll provide screenshots of what happens.

Before firing:image

After firing:image
The missile just stays in the air after firing, nothing even shows in the Output. I will post the code in a separate reply.

Here’s the code:

local TARGET_RADIUS = 5
local MAX_SPEED = 1750
local MAX_TORQUE = Vector3.new(4e6, 4e6, 0)
local MAX_THRUST = 6750
local THRUST_P = 500
local THRUST_D = 500
md = false
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.TargetFilter = script.Value.Value
local running = false
local gun=script.Value.Value
local SPAWN = gun.body:GetPrimaryPartCFrame()
local aimpos = Vector3.new(0,0,0)
rs=game:GetService("RunService").RenderStepped
local canfire = true


function fire()
	if mouse.Target == nil then return end
	if canfire == true and md == true then
		canfire=false
		local thingy = mouse.Target
			local block = Instance.new("Part")
			block.FormFactor = "Custom"
			block.Size =Vector3.new(0.2,0.2,0.2)
			block.Position = mouse.Hit.p
			block.Name="TARGET"
			local pee = script.FOREVERWELD:Clone()
			pee.Disabled=false
			pee.Parent= block
			local weld = Instance.new("Weld") 
			weld.Part0 = block
			weld.Part1 = mouse.Target 
			weld.C0 = block.CFrame:inverse() 
			weld.C1 = mouse.Target.CFrame:inverse() 
			weld.Parent = block
			block.CanCollide=false
			block.Parent=game.Workspace
			block.Transparency=1
			game:GetService("Debris"):AddItem(block,50)
		
		gun.gun.effect.bam:Play()
		local missile= gun.gun.Missile:clone()
		gun.gun.Missile.Transparency=1
		missile.MyTarget.Value = block
		missile.Anchored=false
		missile.Transparency=0
		missile.CFrame = gun.gun.Missile.CFrame
		local a = script.BulletScript:Clone()
		a.Parent = missile
		a.Disabled=false
		missile.Parent=game.Workspace
		
		game:GetService("Debris"):AddItem(missile,45)
		
		
		wait(5)
		gun.gun.Missile.Transparency=0
		canfire=true
		--[[if md == true then
			fire()
		end]]-- not auto
	end
end
function poo()
	mouse.TargetFilter = nil
	mouse.Icon=oldIcon
	gun.gun.Missile.Transparency=0
	script:remove()
end
function no()
	md = false
end
function mousedown()
	md = true
	fire()
end
oldIcon = mouse.Icon
mouse.Icon="http://www.roblox.com/asset/?id=138865017"
person = game.Players.LocalPlayer.Character
person.Humanoid.Jumping:connect(poo)
mouse.Button1Down:connect(mousedown) -- Run function
mouse.Button1Up:connect(no)	
while rs:Wait() do
	aimposa = mouse.Hit.p
	
	if (aimposa-gun.base.Position).magnitude>40 then
	local math = (aimposa-gun.base.Position).magnitude
	aimpos = mouse.Hit.p+Vector3.new(0,100+math*1.5,0)
	
	local c = aimpos
	local x = (gun.gun:GetPrimaryPartCFrame()*CFrame.new(0, 0, -100000)).x
	local y = (SPAWN*CFrame.new(0, 0, -100000)).y
	local z = (gun.gun:GetPrimaryPartCFrame()*CFrame.new(0, 0, -100000)).z
	A = Vector3.new(x,
					y,
					z
					)
	if c then
		gun.gun:SetPrimaryPartCFrame(
			CFrame.new(gun.body:GetPrimaryPartCFrame().p,
			c)
		)
		gun.body:SetPrimaryPartCFrame(
			CFrame.new(
				SPAWN.p,
				A
			)
		)
	else
		gun:SetPrimaryPartCFrame(gun.body:GetPrimaryPartCFrame())
		gun.body:SetPrimaryPartCFrame(
			CFrame.new(
				SPAWN.p,
				A
			)
		)
		end
	end
end

Is the rocket able to be moved after firing it? To put it more simply, are you able to push the rocket? If not, this is probably because the object is anchored.

Another problem you should look at is if the rocket has a BodyVelocity object inside it with the select speed, torque and thrust.

I have taken a look, henceforth, it is not anchored.

It just sits there, its BodyVelocity being 0,0,0.

And you can’t push it around, it’s CanCollide false.

You need to script its velocity using MAX_TORQUE in BodyVelocity. This would also have more of a guarantee to work if you have it using the proper BodyVelocity object rather than using the Velocity property of the rocket.

So…local aimpos = MAX_TORQUE then?

You give a try at trying to fix up the launcher, I have the model link here, where you can see all the scripts. https://www.roblox.com/library/1166562366/Controllable-Turret-7
The “control” LocalScript has the code I provided way above.

Alright, some things I’ve found out:

1.) BodyVelocity has no velocity. You need to add it.
2.) You have to use R6 for the rocket to ‘fire’. You can modify it to be R15 if you wish by using the appropriate body parts.

1 Like

What do I add as the velocity?

Use a velocity speed using Vector3 and make the BodyVelocity.Velocity property use it.
For example:

missile.BodyVelocity.Velocity = Vector3.new(500, 0, 0)

Where would I put that in the script? Show me a clip of YOUR turret working with its modifications.

Nevermind, my answer was not correct.

From the comments, I see that it has not worked after ROBLOX updates though it has worked before.

All I can really say is to rescript the whole system. Or maybe someone else has the answers.

Keep in mind that the control system is run locally, so this does not replicate to the server.

Ah, I see it has been broke due to ROBLOX updates, the comments ARE correct.

You shouldn’t be posting support threads for models you didn’t create and ask people to fix the code for you. That’s not the purpose of this category.

The model is probably “broken” because it’s not compatible with FilteringEnabled. Considering the variables at the top of the code, I’m assuming this is all ran on the client-side. There’s no indication of remotes, so it’s probably only doing things client-side.

Also, in the future, please do edit replies if you have new information to share rather than creating new posts. It looks like bump posting.

2 Likes

Sincerest apologies regarding that.

Another issue of this script is that, the replicated bullet script that goes into the missile may be broken.

Turn this into your own project where you remake it according to new Roblox.

Don’t have enough scripting knowledge to do that.