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

Help With CFraming?

Asked by
Scootakip 299 Moderation Voter
8 years ago
            local customer = game.ReplicatedStorage.Customer
            customer.Name = "Customer"
            customer.Parent = script.Parent
            customer:MoveTo(script.Parent.CustomerSpawner.CFrame + CFrame.new(0,5,0))

Whenever I try this, it says that it expected Vector3 but got CFrame

            local customer = game.ReplicatedStorage.Customer
            customer.Name = "Customer"
            customer.Parent = script.Parent
            customer:MoveTo(script.Parent.CustomerSpawner.CFrame + Vector3.new(0,5,0))

Then is said that it couldn't cast Coordinate Frame to Vector3

            local customer = game.ReplicatedStorage.Customer
            customer.Name = "Customer"
            customer.Parent = script.Parent
            customer:MoveTo(script.Parent.CustomerSpawner.Position + Vector3(0,5,0))

And this makes the customer spawn on the roof rather than where it's supposed to spawn... Some help please? EDIT: This is a model, not a single Part.

0
MoveTo takes a Vector3, it moves the object to the specified Vector3 unless there is stuff in the way (It then moves it upwards to the roof), You should use SetPrimaryPartCFrame. DevSean 270 — 8y

1 answer

Log in to vote
2
Answered by 8 years ago

The reason it spawned on the roof with this code:

local customer = game.ReplicatedStorage.Customer
customer.Name = "Customer"
customer.Parent = script.Parent
customer:MoveTo(script.Parent.CustomerSpawner.Position + Vector3(0,5,0))

Is because Vector3 has collision detection where as CFrame does not.

Try using this if you haven't already

local customer = game.ReplicatedStorage.Customer
customer.Name = "Customer"
customer.Parent = script.Parent
customer:SetPrimaryPartCFrame(CFrame.new(0,5,0))

Make sure to set the primary part of the model first though.

Ad

Answer this question