-
What do you want to achieve? I am trying to get my plugin to fill in my outline but its not working the way I intended.
-
What is the issue? Its creating parts that go through the outline, not filling. (Image attached, gray shape is outline and blue is the filling)
-
What solutions have you tried so far? I’ve tried using triangles, and regular parts but they havent seemed to work either.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
-- local UserInputService = game:GetService('UserInputService')
local DockInfo = DockWidgetPluginGuiInfo.new(
Enum.InitialDockState.Float,
false,
false,
200,
300,
150,
150
)
local Toolbar = plugin:CreateToolbar('theStates | State Maker')
local Mouse = plugin:GetMouse()
local Window = plugin:CreateDockWidgetPluginGui("settings", DockInfo)
Window.Title = 'settings'
plugin:Activate(false)
local Button = Toolbar:CreateButton('theStates | State Maker', 'theStates | State Maker', 'rbxassetid://119293300353858')
local textbox = Instance.new('TextBox', Window)
textbox.Name = 'Thin'
textbox.BackgroundColor3 = Color3.fromRGB(36,36,40)
textbox.TextColor3 = Color3.new(1, 1, 1)
textbox.TextScaled = true
textbox.Font = Enum.Font.Arial
textbox.Size = UDim2.new(1, 0, 1, 0)
textbox.PlaceholderText = 'Type part thiness here, must be a number and below or equal to 2048'
textbox.ClearTextOnFocus = false
local on = false
local deb = false
local lastcf = nil
local lastconnection = nil
local lastconnection2 = nil
local lastconnection3 = nil
local lastpreview = nil
local thin = 1
local max = 2048
local points = {}
local borderFolder = workspace:FindFirstChild("StateOutlines") or Instance.new("Folder", workspace)
borderFolder.Name = "StateOutlines"
function Middle(Position, Position2)
local distance = (Position.p - Position2.p).Magnitude
local huh, size = Position:Lerp(Position2, .5) , Vector3.new(thin, thin, distance)
return huh, size
end
function Draw(Pos1, Pos2)
local Part = Instance.new('Part')
local position, size = Middle(Pos1, Pos2)
Part.Size = size
position = CFrame.new(position.p, Pos2.p)
Part.CFrame = position
Part.Anchored = true
Part.Material = Enum.Material.SmoothPlastic
Part.Color = Color3.fromRGB(255, 255, 255)
Part.Parent = borderFolder
table.insert(points, Pos2.p)
return Part
end
function Place()
if on and Mouse.Target then
print('ok')
local hit = Mouse.Hit
local last = lastcf and lastcf or hit
Draw(hit, last)
lastcf = hit
end
end
local function fillPolygon()
if #points < 3 then
warn("[StateOutliner] Need at least 3 points to fill.")
return
end
local function createFlatTriangle(a, b, c)
local ab = b - a
local ac = c - a
local normal = ab:Cross(ac).Unit
local right = ab.Unit
local back = normal:Cross(right).Unit
local bx = ab.Magnitude
local cx = (c - a):Dot(right)
local cz = (c - a):Dot(back)
local sizeX = math.max(bx, cx)
local sizeZ = math.abs(cz)
local center = (a + b + c) / 3
local triangle = Instance.new("Part")
triangle.Anchored = true
triangle.Size = Vector3.new(sizeX, 0.2, sizeZ)
triangle.CFrame = CFrame.fromMatrix(center, right, normal:Cross(right), normal)
triangle.Material = Enum.Material.SmoothPlastic
triangle.Color = Color3.fromRGB(0, 170, 255)
triangle.Parent = borderFolder
end
local origin = points[1]
for i = 2, #points - 1 do
local p1 = points[i]
local p2 = points[i + 1]
createFlatTriangle(origin, p1, p2)
end
end
textbox.FocusLost:Connect(function()
local input = Window:WaitForChild('Thin').Text
if tonumber(input) and tonumber(input) <= max and #input < 5 then
thin = tonumber(input)
else
warn('Invalid thiness!')
end
end)
Button.Click:Connect(function()
if deb then return print('Cooldown...') end
deb = true
on = not on
Window.Enabled = on
if on == false then
print('Deactivated')
lastcf = nil
if typeof(lastconnection) == 'RBXScriptConnection' then
lastconnection:Disconnect()
end
if typeof(lastconnection2) == 'RBXScriptConnection' then
lastconnection2:Disconnect()
end
if typeof(lastconnection3) == 'RBXScriptConnection' then
lastconnection3:Disconnect()
end
if typeof(lastpreview) == 'Instance' then
lastpreview:Destroy()
end
fillPolygon()
points = {}
else
print('Activated')
local deb2 = false
lastconnection = Mouse.Button1Down:Connect(function()
if not deb2 then
Place()
deb2 = true
task.delay(.2, function() deb2 = false end)
end
end)
lastconnection3 = Mouse.Move:Connect(function()
if typeof(lastpreview) == 'Instance' then
lastpreview:Destroy()
end
local hit = Mouse.Hit
local last = lastcf and lastcf or hit
local Preview = Draw(hit, last)
Preview.Color = Color3.new(0, 1, 0.0823529)
Preview.Material = Enum.Material.SmoothPlastic
Preview.Parent = workspace.CurrentCamera
Preview.Transparency = .5
lastpreview = Preview
end)
end
task.wait(1)
deb = false
end)