Ad
Log in to vote
0

Why doesn't the part go to the position I want it to go?

Asked by 7 days ago
Edited 6 days ago

Got this off roblox-wiki yet funnily enough, the part goes in a completely opposite direction to where I want it to go. Please can someone help me to fix? Does not show any errors or anything like that! The script is used after another identicular script but with a different position.

The code: (The code is in a script in a part, I also added some stuff to it for when it is completed it's movements.)



local Part = script.Parent local newPos = Vector3.new(30.976, 6.022, 8.345) local Time = 1 local Increment = 0.5 local Debounce = false local Diff = newPos - Part.Position local Mag = Diff.magnitude local Direction = CFrame.new(Part.Position, newPos).lookVector function MovePart() if Debounce then return end Debounce = true for n = 0, Mag, Increment do Part.CFrame = Part.CFrame + (Direction * Increment) wait( (Time/Mag) * Increment ) end script.Parent.Orientation = Vector3.new(0, -22.18, 0) Part.Position = Vector3.new(30.976, 6.022, 8.345) Debounce = false end game.Workspace.AnimationValues.Jump.Changed:Connect(function() MovePart() end)
0
you're using Vector3s for a CFrame at line 11 loulou1112 35 — 7d
0
^That's totaly fine, but you should use (Part.Position - newPos).Unit instead. RubenKan 2636 — 7d

Answer this question



Ad