Vector3 Y position

while true do

game.Workspace.Pup.Position = game.Workspace.Pup.Position + Vector3.new(0,2,0)

wait(2)

if game.Workspace.Pup.Position < Vector3(0,20,0) then

else

break

end

end

why it isn’t working? i guess is because “vector3” no a value and if it is bacause of that: how can refere to the “Y” position.

being Pup a part

1 Like

So first, you need to format your code correctly:

Input:
```
--code
```

Output:

--code

And to answer your question, you can refer to the Y position of Vector3s through its Y property:

while true do

	game.Workspace.Pup.Position = game.Workspace.Pup.Position + Vector3.new(0,2,0)
	task.wait(2)

	if game.Workspace.Pup.Position.Y < 20 then
		
	else
		break
	end
end
1 Like

ok thanks i knew about the tap spaces i dont know why they didn’t show.

1 Like

In most cases you can use studio’s intellisense to find out the properties of an object like vector3, by typing a dot (.).

You can do the same with objects with events by typing a full colon ( : )

Vector3


You can acquire the Y-axis through this:
Vector3.Y

Do not misuse the while loops. They work like if statements with breaks if the statement is not matched. Utilizing the while loop’s functionality will avoid the usage of break.

…thus:

while game.Workspace.Pup.Position.Y >= 20 then
    -- your code here 
end
3 Likes

All events are object.Event though, I’m not sure why you would type a colon for that. Colons are only for calling functions, not referencing events.