Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Object's CFrame won't change?

Asked by 5 years ago
Edited 5 years ago

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

0
you need three parameters for 'CFrame.new'. Like this : CFrame.new(x,y,z) tree_tree00 48 — 5y
0
Im sure 100% The CFrame are just teleport for parts banktoner 0 — 5y
0
I had this issue with tweening a door. Instead of moving the door it would move the player, my fix was switching to Vector3. Babyseal1015 56 — 5y

1 answer

Log in to vote
0
Answered by
AizakkuZ 226 Moderation Voter
5 years ago
Edited 5 years ago

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)

Ad

Answer this question