Hey guys, I'm trying to make a homing rocket launcher. The actual problem is that the second script, the one that's supposed to be moved to the rocket, is not working. The first script used to be smashed too, but I realised I had to make it a localscript. Rocket LAUNCHER Script:
script.Parent.Equipped:connect(function (m)
m.KeyDown:connect(function (key)
if key:lower() == "q" then
local p = m.Target
if p:IsA("Part") then
Rocket = Instance.new("Part", game.Workspace)
Rocket.BrickColor = BrickColor.new("Bright red")
Rocket.Size = Vector3.new(1,1,4)
Mesh = script.Parent.Mesh:Clone()
Mesh.Parent = Rocket
Rocket.Position = script.Parent.Handle.Position + Vector3.new(0, 3, 0)
RP = Instance.new("RocketPropulsion", Rocket)
RP.Target = p
RP:Fire()
RP.CartoonFactor = 1
newScript = script.Explosion:Clone()
newScript.Parent = Rocket
newScript.Disabled = false
RP.MaxThrust = 10000
RP.MaxSpeed = 1000
end
end
end)
end)
And the script that goes into the ROCKET:
function GetDistance(Object1, Object2)
return(Object1.Position - Object2.Position).magnitude
end
while true do
script.Value.Value = (GetDistance(script.Parent, script.Parent.RocketPropulsion.Target))
if script.Value.Value > 100 then
script.Parent.RocketPropulsion.MaxSpeed = 250
elseif script.Value.Value < 100 then
script.Parent.RocketPropulsion.MaxSpeed = 125
elseif script.Value.Value < 50 then
script.Parent.RocketPropulsion.MaxSpeed = 75
elseif script.Value.Value > 10 then
script.Parent.RocketPropulsion.MaxSpeed = 25
elseif script.Value.Value < 10 then
script.Parent.RocketPropulsion.MaxSpeed = 15
elseif script.Value.Value == 10 then
script.Parent.RocketPropulsion.MaxSpeed = 20
end
wait(.05)
script.Parent.Touched:connect(function (hit)
e = Instance.new("Explosion", hit)
e.Position = hit.Position
e.ExplosionType = "CratersAndDebris"
e.BlastRadius = 10
script.Parent:Destroy()
end)
end
script.Parent.Touched:connect(function (hit)
e = Instance.new("Explosion", hit)
e.Position = hit.Position
e.ExplosionType = "CratersAndDebris"
e.BlastRadius = 10
script.Parent:Destroy()
end)
I'm not sure what I did wrong, so if anyone could tell me that would be great. Thanks in advance.

3 comments
Erm, actually I DO need it inside as well as it doesn't run if the loop is running on the same timeframe.
Ah ok. So, does it give you any errors in the Output window? I'm looking at the RocketPropulsion to see how it works.
So I just played around with a simple script to test out how well RocketPropulsion works, and it didn't do anything. the propulsion had a target, and I tweaked the thrust values quite a bit, but it still didn't even stop my character from pushing the rocket over. It could be semi-depricated, so I'd suggest using BodyPosition instead, which will need a loop to update the target position.