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

How do I get the mouse position in a plugin?

Asked by
Prioxis 673 Moderation Voter
9 years ago

I'm making a plugin that will place a brick at the persons mouse position

I marked the areas in the code with comments on where I need help

with what i'm trying to accomplish

local version = "1.0.0"
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
function OB1D(mousee)
local HTarget = mouse.Target  -- where I need help
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

mouse.mouseButton1Down:connect(function()
local part = Instance.new("Part",game.Workspace)
part.Position = mouse.Hit -- where I need help
end);
mouse.mouseButton1Up:connect(function()
On=false;
end);

button.Click:connect(function()
    if On == true then
        On = false
    else
        On = true
    end
end)

1 answer

Log in to vote
0
Answered by 9 years ago

You need to pass the mouse as a parameter to the function

--ex

mouse.MouseButton1Down:connect(function(Mouse)
--mouse stuff here
end)
Ad

Answer this question