Hey! So I'm working on a plugin that makes smooth-looking pipes, and I just finished the main scripting part so that I can release it under testing, but when I published and ran the plugin, my script(s?) just didn't do anything.

I have two main scripts, one to create the toolbar and buttons, and one to handle all the placement and button clicks.

Here is the first script:

local toolbar = plugin:CreateToolbar("PIPE TOOL | V1")
local newButton = toolbar:CreateButton("Create Pipes", "Click me to start placing smooth pipes!", "rbxassetid://1")

newButton.Click:Connect(function(newButtonClick)
	local Clone = script.PIPETOOLPlugin.MainUI:Clone()
	Clone.Parent = game.CoreGui
end)

and here is the second script:

-- // Value Stuff
local Values = script.Parent.Parent.Parent.Values

local CanStart = true
local isPlacing = Values.IsPlacingPipe.Value == nil
local CanPlace = nil

local StudsMovement = Values.StudsValue.Value
local XSize = Values.XSizeValue.Value
local YSize = Values.YSizeValue.Value
local ZSize = Values.ZSizeValue.Value

local PipeColor = Values.PipeColor.Value
local JointColor = Values.JointColor.Value
local PipeMaterial = Values.PipeMaterial.Value
local JointMaterial = Values.JointMaterial.Value


-- // UI Elements
local MainUI = script.Parent.Parent
local Button = script.Parent

-- // Start of Code
Button.MouseButton1Click:Connect(function(ButtonPressed)
	local Player = game.Players.LocalPlayer -- Will only work when parented to CoreGui
	-- which is what happens when the user presses the plugin button.
	local Mouse = Player:GetMouse() -- Gets mouse of player
	
	local PosX
	local PosY
	local PosZ
	
	local GridSize = 2
	
	local Part = Instance.new("Part", game.Workspace) --Our part being placed
	Part.Shape = Enum.PartType.Cylinder
	Part.Size = Vector3.new(6, 1, 1)
	Part.Anchored = true
	Part.Name = "PIPE"
	Part.Transparency = 1
	
	local SelectionBox = Instance.new("SelectionBox", Part) -- SelectionBox around the part
	SelectionBox.Color3 = Color3.fromRGB(0, 255, 127)
	SelectionBox.LineThickness = 0.1
	SelectionBox.SurfaceColor3 = Color3.fromRGB(85, 255, 0)
	SelectionBox.SurfaceTransparency = 0.8
	SelectionBox.Transparency = 0
	
	local function Snap()
		PosX = math.floor(Mouse.Hit.X / GridSize + 0.5) * GridSize
		PosY = 3
		PosZ = math.floor(Mouse.Hit.Z / GridSize + 0.5) * GridSize
	end
	
	local function Placement()
		if (isPlacing and CanPlace == true) then
			local PlacingPart = Part:Clone()
			PlacingPart.Transparency = 0
			
			isPlacing = false
			CanPlace = false
			CanStart = true
		end
	end
	
	local function Movement()
		Mouse.TargetFilter = Part
		
		Snap()
		
		Part.CFrame = CFrame.new(PosX, PosY, PosZ)
	end
	
	local function StartPlacement()
		if (CanStart) then
			isPlacing = true
			CanPlace = true
			CanStart = false
			
			Mouse.Move:Connect(Movement)
		end
	end
	
	Mouse.Button1Down:Connect(Placement)
	Button.MouseButton1Click:Connect(StartPlacement)
end)

I'm not getting any errors, and I'm really stumped, please help!

3 comments

0

From what I know, I have had a go at making a plugin before and I tried adding it to CoreGui. It doesn't seem to work. I read somewhere that you have to make it manually by script. I also saw something on the devforums about LuaDockWidgets so I would recommend looking there. Good luck ????

0

I saw that exact same post, they said it would just be fine parenting it to core gui, do you think its my script types? the first script is a script, and the second one is a local script

0

or do you think its because core gui cant access local player?