How do I set a models position? Since a models property doesn't have a position point. How do I set a models position to my mouses hit position. Whenever I press play and activate my tool it clones the model and puts the position of the model in the origin of the studio. And the output gives me a error saying "16:32:37.090 - Position is not a valid member of Model"
local tool = script.Parent.Parent local ReplicatedStorage = game.ReplicatedStorage local RepThermite = ReplicatedStorage.RepThermite local plr = game.Players.LocalPlayer local Mouse = plr:GetMouse() tool.Activated:Connect(function() local Clonedthermite = RepThermite:Clone() Clonedthermite.Parent = game.Workspace Clonedthermite.Position = Mouse.hit.p end)
Use Clonedthermite:SetPrimaryPartCFrame(Mouse.Hit)
Note: if your model does not have a primary part, then give it one.
You can use this for mouse location:
local mouseLocation = game:GetService("UserInputService"):GetMouseLocation()
Then cast a ray from the camera:
local unitRay = camera:ScreenpointToRay(mouseLocation.X, mouseLocation.Y) local newRay = Ray.new(unitRay.Origin, unitRay.Direction * 100) -- 100 is the distance
Then you cast this ray on workspace:
local part, position, normal = workspace:FindPartOnRay(newRay, character) -- ignore the character in the ray -- we don't use part or normal as they're not needed Clonedthermite.Position = position
This is the basic way of setting it at a max of 100 studs where the mouse is
Here is a more advanced tutorial that teaches you how to do it specifically without UserInputService but the Mouse object is generally superseded by UserInputService so it's up to you: https://devforum.roblox.com/t/dragging-objects-with-the-mouse/403766