Script
lua
local function RocketStart(Targets, Hooks, MG, Beams)
Gyro.P = 1000
Humanoid.AutoRotate = false
Targets.Parent = workspace.Terrain
Targets.Position = mouse.Hit.Position
Hooks.Weld.Part0 = nil
Hooks.Parent = MG
Hooks.Position = MG.Position
Hooks.CFrame = CFrame.new(Hooks.Position, Targets.Position)
Beams.Texture = "rbxassetid://2935383234"
Beams.Width0 = 1
Beams.Width1 = 1
local Time = ((Hooks.Position - Targets.Position)/400).Magnitude
local TweenInfos = TweenInfo.new(Time, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local tween = TweenService:Create(Hooks, TweenInfos, {Position = Targets.Position})
tween:Play()
tween.Completed:Connect(function()
Hookson = true
Hooks.Weld.Part0 = Targets
RocketAdjust(Rocket, Targets, 400, 7000)
Beams.Texture = ""
Beams.Width0 = 0.1
Beams.Width1 = 0.1
end)
end
Explanation The first part of the script sets everything that will run until the tween is complete, once the tween is complete, it fires a rocket that's attached to the player by using a function.
Problem The script is working fine, the only line that I have a problem with is:
Hooks.CFrame = CFrame.new(Hooks.Position, Targets.Position)
The object (hooks) won't face it's target, it will just stay in its original position and rotation instead of facing the target. The line is working, but the object (hooks) won't change according to the CFrame. How will I fix this? is there something in the function that's blocking it?
Edited:
Here's also the second script that end everything that started in the first function
lua
local function RocketEnd(Targets, Hooks, MG, Beams)
Gyro.P = 0
Humanoid.AutoRotate = true
Hooks.Anchored = false
RocketAdjust(Rocket, HRP, 0, 0)
Targets.Parent = nil
Beams.Texture = "rbxassetid://2935383234"
Beams.Width0 = 1
Beams.Width1 = 1
local Time = ((Hooks.Position - MG.Position)/400).Magnitude
local TweenInfos = TweenInfo.new(Time, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local tween = TweenService:Create(Hooks, TweenInfos, {Position = MG.Position})
tween:Play()
tween.Completed:Connect(function()
Hookson = false
Hooks.Weld.Part0 = MG
Beams.Texture = ""
Beams.Width0 = 0.1
Beams.Width1 = 0.1
end)
end
Try finding a players part by finding a part in this case i'll use HumanoidRootPart then make the Rocket shoot from that using CFrame This first finds the part in the character after, it finds HumanoidRootPart then, put's whatever part in the position 0,0,0 corresponding to the HumanoidRootPart Please respond and tell me if this helped?
lua
PARTNAME.Character:FindFirstChild("HumanoidRootPart").CFrame * CFrame.new(0, 0, 0)