I was using CFrame to move a block back and forth, but need a way for it to also move the player. I tried using velocity, and it worked, but I couldn't seem to figure out how to code it into the script (as the block moves back and forth). Could someone help me with this?
Here's the code I currently have:
local brick=script.Parent while wait(0.5) do for I=1,50 do brick.CFrame=brick.CFrame+Vector3.new(0.5,0,0) wait() end wait(0.5) for I=1,50 do brick.CFrame=brick.CFrame+Vector3.new(-0.5,0,0) wait() end end
The only thing that you did wrong is forget to put CFrame.new in front of the value you want to change it to. Adding it would make your script look like this:
local brick=script.Parent while wait(0.5) do for I=1,50 do brick.CFrame=CFrame.new(brick.CFrame+Vector3.new(0.5,0,0)) wait() end wait(0.5) for I=1,50 do brick.CFrame=CFrame.new(brick.CFrame+Vector3.new(-0.5,0,0)) wait() end end
Okay. I don't know if I explained this correctly before. I have a platform moving with CFrame. I need it to also move the player. Editing the Velocity value in a brick will turn it into a conveyor belt, which I figured would work. The brick moves just fine. I need to know how to change the Velocity value of the brick via the script so when the brick moves forward, the player moves forward, and vice versa.
ive modified your script so the player moves alongisde the part,
local brick=script.Parent while wait(0.5) do brick.Velocity = Vector3.new(15,0,0) for I=1,50 do brick.CFrame=brick.CFrame+Vector3.new(0.5,0,0) wait() end brick.Velocity = Vector3.new(0,0,0) wait(0.5) brick.Velocity = Vector3.new(-15,0,0) for I=1,50 do brick.CFrame=brick.CFrame+Vector3.new(-0.5,0,0) wait() end brick.Velocity = Vector3.new(0,0,0) end
however i still strongly suggest you use body movers
this is the code for a 6x1x6 part,
BodyGyro; maxtorque = 400000, 400000, 400000 p=10000
BodyPosiiton mastorque = 100000, 100000, 100000 p = 5000 positon = (varies)
script;
local model = script.Parent local platform = model.Platform local bodyPos = platform.BodyPosition local pos1 = platform.Position local pos2 = (platform.CFrame*CFrame.new(14,0,0)).p local waitTime = 2 bodyPos.position = pos1 platform.Anchored = false local currentPos = pos1 while wait(waitTime) do if currentPos == pos1 then currentPos = pos2 bodyPos.position = pos2 elseif currentPos == pos2 then currentPos = pos1 bodyPos.position = pos1 end end