Im trying to make a script that teleports a model to the mouses CFrame position! Please Help :D
Output: 18:06:23.346 - CoordinateFrame is not a valid member
1 | target = game.Players.LocalPlayer:GetMouse().Hit |
2 | game.Workspace.Model:MoveTo(target) |
The method MoveTo takes a Vector3, not a CoordinateFrame.
Mouse.Hit returns a CoordinateFrame.
http://wiki.roblox.com/index.php?title=API:Class/Mouse/Hit http://wiki.roblox.com/index.php?title=API:Class/Model/MoveTo
1 | target = game.Players.LocalPlayer:GetMouse().Hit |
2 | game.Workspace.Model:MoveTo(Vector 3. new(target)) |
Using the Vector3 constructor on the CFrame is a simple and quick way to convert.
To move models with CFrame, you should use :SetPrimaryPartCFrame(**arg1**CFrame)
instead of :MoveTo(**arg1** Vector3)
.
To use :SetPrimaryPartCFrame()
, you should first set PrimaryPart by Model's Properties Tab.
After setting that, you will be able to use it.
1 | local plr = game.Players.LocalPlayer |
2 | local mouse = plr:GetMouse() |
3 | local model = workspace:WaitForChild( "ModelName" ) |
4 |
5 | model:SetPrimaryPartCFrame(mouse.Hit) |