Right before I was about to post a question on why this script wasn't working, I changed an addition to subtraction and viola!
Anyways as the question name suggests, how or what do I have to put into this code to make the character move along with the block.
Does it involve CFraming the player along with their position?
local Part = script.Parent -- this is the Part we will move local start = script.Parent.Start.Value local finish = script.Parent.Finish.Value local Time = 5 -- the time that the script will take to move the part local Increment = 0.1 -- the Part will move 0.1 studs each time it moves local Debounce = false local Diff = finish - Part.Position -- the difference between the two positions local Mag = Diff.magnitude -- the distance between the two parts local Direction = CFrame.new(Part.Position, finish).lookVector --local Diff2 = start - Part.Position --All of this became useless once I fixed my code --local Mag2 = Diff2.magnitude --I'll keep it for reference --local Dir2 = CFrame.new(Part.Position, start).lookVector -- and to shame myself eternally function MovePart() -- function to move the Part if Debounce then return end -- end the function if debounce is true Debounce = true -- make Debounce true so the function can't run for n = 0, Mag, Increment do Part.CFrame = Part.CFrame + (Direction * Increment) wait( (Time/Mag) * Increment ) end wait(3) for n = 0, Mag, Increment do Part.CFrame = Part.CFrame - (Direction * Increment) --Used to be a plus *Derp* wait( (Time/Mag) * Increment ) end Debounce = false end workspace.Button.ClickDetector.MouseClick:connect(MovePart)
The ClickDetector is there for debugging and the likes, which will be replaced with a loop.
https://gyazo.com/89243d997d2c5d0a97ecf9c8aba3b9d7 (Gif showing heiarchy and the previously broken segment Ignore disappearing issue)
Thank you for any help!
~MBacon15
I worked with this before. So the best thing you can do is to Use BodyMoverObjects. This is because you want the Player to move with the brick, but since you're using CFrame to move the brick, the physics of the brick's movement doesn't exist. So what this does, it Ignores Friction, friction is what grips the player onto the brick . I really suggest to Use BodyPosition , because it uses existing physics. I know this might sound funny, but this is how it realistic it gets. I hope I helped!