Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you make it so when you click anywhere with a Tool it clones a Model?

I want to make it so when you click anywhere on a Tool, it Clones the model to where the Player's mouse clicks. Does anyone know how to get started on this?

2 answers

Assuming your model is in the ReplicatedStorage service (which it should be), this LocalScript (which should be placed in the StarterGui or StarterPack) will put a clone of that model wherever the user clicks. Only when a part is clicked, of course.

NOTE: This also checks and will work with a part or a model.

local p = Game.Players.LocalPlayer
local m = p:GetMouse();
local model = Game.ReplicatedStorage['Model Name'];

m.Button1Down:connect(function()
    if m.Target then
		local x = model:Clone()
        if x:IsA("Model") then
			x.Parent = Workspace
			x:MoveTo(m.Hit.p)
        elseif x:IsA("BasePart") then
			x.Parent = Workspace
            x.Position = m.Hit.p
        end
    end
end)

5 comments

0

It didn't work. I clicked on the Base and nothing happened, and same with a Part. I also changed the Model name to the Model and put it in ReplicatedStorage,

0

I've edited to fix the bug. I was using MouseButton1Down when it should be Button1Down. The clone was also never parented.

0

Thank's it works. But I have a question. Whenever I click it makes the Model. Do you know how to fix it so it only clones when you click with the Tool? I even put the script in the tool but it clones without it.

0

Shouldn't be too difficult. Learn how to use the Equipped event of a tool to get the mouse. Instead of using 'm' from GetMouse(), use the Equipped event of a tool to get the mouse.

For getting the position where the Player's mouse clicks use mouse.Hit. Then :Clone() the model from ReplicatedStorage.

This discussion is preserved as it was. New answers, comments, and votes are closed.