Explanation
Basically I want it so when I click a button it will fire a missile, I got everything working perfectly… except the RocketPropulsion, when I do :Fire() nothing happens at all. So I tried putting it in another part with a script that just had two lines wait(5) and then :Fire() and it worked perfectly
(Their are not errors even when I remove the Pcall)
My Script
local PHPX = game.Workspace.PlaceHolderPart.Position.X
local PHPY = game.Workspace.PlaceHolderPart.Position.Y
local PHPZ = game.Workspace.PlaceHolderPart.Position.Z
local Sam1In = false
local Sam2In = false
local Sam3In = false
local Sam4In = false
local SAM1 = nil
local SAM2 = nil
local SAM3 = nil
local SAM4 = nil
game.Workspace.FireTest.ClickDetector.MouseClick:Connect(function()
pcall(function()
if Sam1In then
SAM1.RocketPropulsion:Fire()
SAM1.SamFins.Anchored = false
SAM1.SamBody.Anchored = false
Sam1In = false
print("Sam1In = ", Sam1In)
elseif Sam2In then
SAM2:Destroy()
Sam2In = false
print("Sam2In = ", Sam2In)
elseif Sam3In then
SAM3:Destroy()
Sam3In = false
print("Sam3In = ", Sam3In)
elseif Sam4In then
SAM4:Destroy()
Sam4In = false
print("Sam4In = ", Sam4In)
end
end)
end)
game.Workspace.RestockTest.ClickDetector.MouseClick:Connect(function()
if not Sam1In then
Sam1In = true
print("Sam1In = ", Sam1In)
local RestockSAM1 = game.Workspace.Sam1Holder:Clone()
RestockSAM1.SamFins.Position = Vector3.new(PHPX+3.951, PHPY+0.705, PHPZ-0.896)
RestockSAM1.SamBody.Position = Vector3.new(PHPX+2.5, PHPY+0.7, PHPZ-0.9)
RestockSAM1.Parent = game.Workspace
SAM1 = RestockSAM1
elseif not Sam2In then
Sam2In = true
print("Sam2In = ", Sam2In)
local RestockSAM2 = game.Workspace.Sam1Holder:Clone()
RestockSAM2.SamFins.Position = Vector3.new(PHPX+3.951, PHPY+0.705, PHPZ+1.104)
RestockSAM2.SamBody.Position = Vector3.new(PHPX+2.5, PHPY+0.7, PHPZ+1.1)
RestockSAM2.Parent = game.Workspace
SAM2 = RestockSAM2
elseif not Sam3In then
Sam3In = true
print("Sam3In = ", Sam3In)
local RestockSAM3 = game.Workspace.Sam1Holder:Clone()
RestockSAM3.SamFins.Position = Vector3.new(PHPX+3.951, PHPY-1.295, PHPZ-0.896)
RestockSAM3.SamBody.Position = Vector3.new(PHPX+2.5, PHPY-1.295, PHPZ-0.9)
RestockSAM3.Parent = game.Workspace
SAM3 = RestockSAM3
elseif not Sam4In then
Sam4In = true
print("Sam4In = ", Sam4In)
local RestockSAM4 = game.Workspace.Sam1Holder:Clone()
RestockSAM4.SamFins.Position = Vector3.new(PHPX+3.951, PHPY-1.295, PHPZ+1.104)
RestockSAM4.SamBody.Position = Vector3.new(PHPX+2.5, PHPY-1.295, PHPZ+1.1)
RestockSAM4.Parent = game.Workspace
SAM4 = RestockSAM4
end
end)