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

Model moving script help?

Asked by
JJ_B 250 Moderation Voter
8 years ago

I making a script where a model moves in one direction. There are no errors in the output, but it just prints the line in blue and the script fails to work. Here is the code around that line.

local p = game.Workspace.Stardrive:GetChildren()
        for i = 1,#p do
        repeat
            p.CFrame = p.CFrame + Vector3.new(0,0,10)
        until
            game.Workspace.Stardrive.Shape.Positon == Vector3.new(-37.96, 16.255, 868.946)
        end

Can anybody help to identify the problem?

0
You're giving as specific position so instead use the greater/less than or equal to sign for the == so change p.CFame = CFrame.new( p.Position +Vector3.new(0,0,10)) until game.Workspace.Stardrive.Shape.Position.X >= 868.946 DevScripting 92 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

You're giving as specific position so instead use the greater/less than or equal to sign for the == sign because it's most likely not to be exactly at the position so give a better answer by if it goes over or if it is exact then stop moving it

local stardrive = game.Workspace:WaitForChild("Stardrive")
local shape = stardrive:WaitForChild("Shape")
local p = stardrive:GetChildren()

for i = 1,#p do
        repeat
            p.CFrame = p.CFrame + Vector3.new(0,0,10)
        until
            shape.Positon.Z <= 868.946
end

So I added :WaitForChild() it's a built-in roblox function that yield until that instance is not nil (until the instance exists )

Ad

Answer this question