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

How do I get the mouse position in a plugin?

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

✓ Accepted answer

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

--ex

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

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