Trying to make it where when a Player presses 'Q', the model clones to the workspace and the player can place it wherever they please on a 1 stud increment. I keep getting the error: "Unable to cast double to CoordinateFrame"
01 | local model = game.ReplicatedStorage.Model |
02 |
03 | local mouse = game.Players.LocalPlayer:GetMouse() |
04 |
05 |
06 |
07 |
08 | mouse.KeyDown:connect( function (key) |
09 | if key = = "q" then |
10 | local newModel = model:Clone() |
11 | newModel.Parent = game.Workspace |
12 | newModel:SetPrimaryPartCFrame(mouse.X,mouse.Y) |
13 | end |
14 | end ) |
The SetPrimaryPartCFrame
requires a CFrame value but instead you gave it two values; mouse.X,
and mouse.Y
If you're trying to move it by 1 stud increments, you're going to have to use math.floor
or math.ceil
01 | local model = game.ReplicatedStorage.Model |
02 |
03 | local mouse = game.Players.LocalPlayer:GetMouse() |
04 |
05 |
06 |
07 |
08 | mouse.KeyDown:connect( function (key) |
09 | if key = = "q" then |
10 | local newModel = model:Clone() |
11 | newModel.Parent = game.Workspace |
12 | newModel:SetPrimaryPartCFrame(CFrame.new(math.floor(mouse.Hit.p.X),math.floor(mouse.Hit.p.Y),math.floor(mouse.Hit.p.Z))) |
13 | end |
14 | end ) |
That should work.