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

Model won't move back and forth?

Asked by 4 years ago
Edited 4 years ago

I want the model to move forward go back to start then repeat forever but it won't move at all and there are no errors

workspace.Road.PrimaryPart = workspace.Road.Center

while true do
    for i = 1,100 do
        wait(0.01)

        workspace.Road.SetPrimaryPartCFrame(CFrame.new(workspace.Road.PrimaryPart.Position + Vector3.new(0,0,1)))
    end

    wait(0.01)
        for i = 1,1 do
        wait(0.01)

        workspace.Road.SetPrimaryPartCFrame(CFrame.new(workspace.Road.PrimaryPart.Position - Vector3.new(0,0,100)))  

    end
    wait(0.01)
end
0
Do they stay at the same position or you can't see them? Xapelize 2658 — 4y
0
It stays in the same spot Fervantpigeon47 31 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

The problem is you're using .SetPrimaryPartCFrame, while the correct way is using ":" just like so :SetPrimaryPartCFrame. So here is how the script is:

workspace.Road.PrimaryPart = workspace.Road.Center

while true do
    for i = 1,100 do
        wait(0.01)

        workspace.Road:SetPrimaryPartCFrame(CFrame.new(workspace.Road.PrimaryPart.Position + Vector3.new(0,0,1)))
    end

    wait(0.01)
        for i = 1,1 do
        wait(0.01)

        workspace.Road:SetPrimaryPartCFrame(CFrame.new(workspace.Road.PrimaryPart.Position - Vector3.new(0,0,100)))  

    end
    wait(0.01)
end
Ad
Log in to vote
0
Answered by
JesseSong 3916 Moderation Voter Community Moderator
4 years ago

That's because the function :SetPrimaryPartCFrame is a inbuilt function by roblox which moves a model you forgot to add the COLON on :SetPrimaryPartCFRAME

To learn more about SetPrimaryPartCFrame: https://developer.roblox.com/en-us/api-reference/function/Model/SetPrimaryPartCFrame

Answer this question