I'm making a rocket launcher and I want the rocket that the tool makes to be in FRONT of the launcher instead of in it. Because if the part is made inside of the launcher, they touch eachother and it explodes instantly.
local debounce = false script.Parent.Activated:Connect(function() if debounce == false then debounce = true local char = script.Parent.Parent local rocket = Instance.new("Part") rocket.CFrame = script.Parent.Handle.CFrame --< Makes it inside of it instead of in the front rocket.Parent = workspace local BV = Instance.new("BodyVelocity") BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge) BV.Velocity = char.HumanoidRootPart.CFrame.lookVector*50 BV.Parent = rocket local exploscript = script.Parent.ExploScript:Clone() exploscript.Parent = rocket exploscript.Disabled = false wait(1) debounce = false end end)
You would use toWorldSpace to do this.
Edit: Sorry, my old code wouldn’t work as I didn’t read the article I got it from right.
local debounce = false local pos = CFrame.new(PUTROCKETPARTHERE.Position) * CFrame.new(0,0,-5)— fixed local pos2 = PUTROCKETPARTHERE.CFrame:toWorldSpace(pos) script.Parent.Activated:Connect(function() if debounce == false then debounce = true local char = script.Parent.Parent local rocket = Instance.new("Part") rocket.CFrame = pos2 rocket.Parent = workspace local BV = Instance.new("BodyVelocity") BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge) BV.Velocity = char.HumanoidRootPart.CFrame.lookVector*50 BV.Parent = rocket local exploscript = script.Parent.ExploScript:Clone() exploscript.Parent = rocket exploscript.Disabled = false wait(1) debounce = false end end)
I think this would work, I’m not really sure. If this doesn’t work, look on the wiki about toWorldSpace.