Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I create a part at my mouse position using a plugin?

Asked by
Prioxis 673 Moderation Voter
9 years ago

So i'm creating a plugin that will make a tree (part with a mesh) at wherever I click But I don't really know how to accomplish this it's been awhile since i've been on roblox studio/used lua

so far heres my script

local version = "1.0.0" -- plugin stuff
local plugin = PluginManager():CreatePlugin()
local toolbar = plugin:CreateToolbar("Hello World Plugin")
local button = toolbar:CreateButton(
    "Tree Creator", -- The text next to the icon. Leave this blank if the icon is sufficient.
    "Click to make tree!", -- hover text
    ""
)
local On = false
local player
local mouse = player.GetMouse()
function OB1D(mousee) -- create tree function \/\/\/\/\/
local HTarget = mouse.Target 
local HPosition = mouse.Hit.p 
local NewPart = Instance.new("Part")
NewPart.Anchored = true 
NewPart.Parent = game.Workspace
NewPart.Position = HPosition
local Mesh = Instance.new("SpecialMesh", NewPart)
Mesh.MeshId = "http://www.roblox.com/asset/?id=150251147"
Mesh.Scale = Vector3.new(3.1, 3.1, 3.1)
Mesh.TextureId = "http://www.roblox.com/asset/?id=150251554"
NewPart.Size = CFrame.new(2, 3, 31.6) 
end

button.Click:connect(function() -- click the plugin button
On = true
end)

if On == true then
mouse.Button1Down:connect(function(create) -- where I need help 

end)
end

1 answer

Log in to vote
2
Answered by 9 years ago

Just put this under the MouseButton1Down function.

local part = Instance.new("Part",game.Workspace)
part.Position = mouse.Hit

If it works please vote up and accept answer!

Ad

Answer this question