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

How do I use :toWorldSpace?

Asked by 4 years ago

The devforum page tells me absolutely nothing, and just confuses me. How do I use this with MoveTo aswell?

2 answers

Log in to vote
0
Answered by 4 years ago

It is a function you call on a CFrame. It is the equivalent of a CFrame made relative to the world's center (0, 0, 0) and also equivalent to just doing CFrame times CFrame.

local cf = CFrame.new(0, 5, 0)
print(cf.Position.Y) -- 5
cf = cf:ToWorldSpace(CFrame.new(0, 10, 0))
print(cf.Position.Y) -- 15

An alternative function that uses a Vector3 instead is called :PointToWorldSpace() which will do exactly the same thing but relatively with a Vector3 instead of a CFrame.

You can find more out here.

Ad
Log in to vote
-1
Answered by
raid6n 2196 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

:ToWorldSpace() returns a CFrame relative to the center of the world (0, 0, 0). So if object C’s CFrame is 0, 10, 0 away from 0, 0, 0, it would return 0, 10, 0. link

0
But how do I use it? iiDkOffical 109 — 4y

Answer this question