Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Model moving script help?

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?

1 comment

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

1 answer

✓ Accepted answer

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 )

This discussion is preserved as it was. New answers, comments, and votes are closed.