How can this be done? Is this possible? Because i tried it and i can't seem to know how cursor works like i don't see any properties to do so. Thanks. I don't need the script by the way i just need to be enlighten
✓ ANSWER ACCEPTED
Directly clone a part from your cursor?
1 answer
✓ Accepted answer
It is possible to clone a part from your cursor. You need to get the position of the cursor and then clone the part, setting it's position to the position of the cursor.
Fortunately, there is a property called Hit in the Mouse which returns the CFrame of the mouse in the 3D space. which eliminates most of the hard work. You can convert this to a Vector3 by adding .p to the end of the Hit property.This basically converts the CFrame into a Vector3.
An example of what you could do is this (use a LocalScript and put it in StarterPack):
local player = game.Players.LocalPlayer --Gets the local player.
local mouse = player:GetMouse() --Gets the player's mouse
local part = game.Workspace.Part --You can change this to your part.
local db = false --Debounce variable, which is used to make the function only run once when the mouse is clicked.
mouse.Button1Down:connect(function() --Fires a function when the mouse is clicked.
local hit = mouse.Hit.p --Get the position of the cursor in 3D space.
local pClone = part:Clone()
pClone.Parent = workspace --Global variable for game.Workspace.
pClone.Position = hit --Moves the part to where the cursor is in 3D space.
end) --Closing parenthesis to wrap the function in the connection line.
I hope this helped you. If it did, be sure to accept my answer.
This discussion is preserved as it was. New answers, comments, and votes are closed.
