When I click the mouse, the game spawns in a model to my mouse position but I dont know how to set the model's position to the mouse position without rotating the model. It's taken me ages to try figure it out but i cant get my head around Cframe.
local player = game.Players.LocalPlayer local mouse = player:GetMouse()
function place()
local foundation = game.ReplicatedStorage.Foundation:Clone()
foundation.Parent = game.Workspace
local x, y, z = mouse.Hit:toEulerAnglesXYZ()
foundation:SetPrimaryPartCFrame(mouse.Hit.Position * CFrame.fromEulerAnglesXYZ(-x,-y,-z))
end
mouse.Button1Up:connect(place)
I tried this myself and it seemed to work fine...but I am sure there are probably much easier ways to do it
local mouse = game.Players.LocalPlayer:GetMouse() function place() local foundation = game.Workspace.Model local primPart = foundation.Part foundation.PrimaryPart = primPart foundation:SetPrimaryPartCFrame(primPart.CFrame + (mouse.Hit.p - primPart.CFrame.p)) end mouse.Button1Up:connect(place)