local function G(G,t,q,U,O)local j=Instance.new("\067\121\108\105\110\100\101\114\072\097\110\100\108\101\065\100\111\114\110\109\101\110\116")j.Name=G.."\066\111\100\121"j.Color3=U j.Radius=.15 j.Adornee=workspace.Terrain j.Transparency=0 j.Radius=.15*q j.Transparency=0 j.AlwaysOnTop=true j.ZIndex=O j.Parent=t local c=Instance.new("\067\111\110\101\072\097\110\100\108\101\065\100\111\114\110\109\101\110\116")q=q==1 and 1 or 1.4 c.Name=G.."\080\111\105\110\116"c.Color3=U c.Radius=.5*q c.Transparency=0 c.Adornee=workspace.Terrain c.Height=2*q c.AlwaysOnTop=true c.ZIndex=O c.Parent=t end local function t(G,t,q,U,O)G.Height=(q-U).magnitude-2 G.CFrame=CFrame.lookAt((q+U)/2-(U-q).unit*1,U)t.CFrame=CFrame.lookAt((CFrame.lookAt(U,q)*CFrame.new(0,0,-2-(O-1)/2)).p,U)end local q=require(script.Parent.Parent.Runtime)return q.widget(function(U,O,j)local c=q.useState((BrickColor.random()).Color)j=j or c if typeof(U)=="\073\110\115\116\097\110\099\101"then if U:IsA("\066\097\115\101\080\097\114\116")then U=U.CFrame elseif U:IsA("\065\116\116\097\099\104\109\101\110\116")then U=U.WorldCFrame end if O~=nil then U=U.p end end if typeof(O)=="\073\110\115\116\097\110\099\101"then if O:IsA("\066\097\115\101\080\097\114\116")then O=O.Position elseif O:IsA("\065\116\116\097\099\104\109\101\110\116")then O=O.WorldPosition end end if typeof(U)=="\067\070\114\097\109\101"and O==nil then local G=U.lookVector O=U.p U=O+G*-10 end if O==nil then O=U U=O+Vector3.new(0,10,0)end assert(typeof(U)=="\086\101\099\116\111\114\051"and typeof(O)=="\086\101\099\116\111\114\051","\080\097\115\115\101\100 \112\097\114\097\109\101\116\101\114\115 \097\114\101 \111\102 \105\110\118\097\108\105\100 \116\121\112\101\115")local L=q.useInstance(function(t)local q=Instance.new("\070\111\108\100\101\114")q.Name="\065\114\114\111\119"t.folder=q G("\102\114\111\110\116",q,1,j,1)G("\098\097\099\107",q,2,Color3.new(0,0,0),-1)return q end)local Y=L.folder t(Y.frontBody,Y.frontPoint,U,O,1)t(Y.backBody,Y.backPoint,U,O,1.4)Y.frontBody.Color3=j Y.frontPoint.Color3=j end)
--[=[
	@within Plasma
	@function arrow
	@tag widgets
	@param from Vector3 | CFrame | BasePart
	@param to Vector3 | BasePart | nil
	@param color Color3? -- Optional color. Random if not specified.

	- `arrow(from: Vector3, to: Vector3)` -> Creates an arrow between `from` and `to`
	- `arrow(point: Vector3)` -> Creates an arrow pointing at `point`
	- `arrow(cframe: CFrame)` -> Creates an arrow with its point at the CFrame position facing the CFrame LookVector
	- `arrow(part: BasePart)` -> Arrow represents the Part's CFrame
	- `arrow(fromPart: BasePart, toPart: BasePart)` -> Arrow between the two parts

	![Arrows](https://i.eryn.io/2150/arrows.png)

	```lua
	Plasma.arrow(Vector3.new(0, 0, 0))
	Plasma.arrow(Vector3.new(5, 5, 5), Vector3.new(10, 10, 10))
	```
]=]

local function arrow(name, container, scale, color, zindex)
	local body = Instance.new("CylinderHandleAdornment")

	body.Name = name .. "Body"
	body.Color3 = color
	body.Radius = 0.15
	body.Adornee = workspace.Terrain
	body.Transparency = 0
	body.Radius = 0.15 * scale
	body.Transparency = 0
	body.AlwaysOnTop = true
	body.ZIndex = zindex

	body.Parent = container

	local point = Instance.new("ConeHandleAdornment")

	scale = scale == 1 and 1 or 1.4

	point.Name = name .. "Point"
	point.Color3 = color
	point.Radius = 0.5 * scale
	point.Transparency = 0
	point.Adornee = workspace.Terrain
	point.Height = 2 * scale
	point.AlwaysOnTop = true
	point.ZIndex = zindex

	point.Parent = container
end

local function update(body, point, from, to, scale)
	body.Height = (from - to).magnitude - 2
	body.CFrame = CFrame.lookAt(((from + to) / 2) - ((to - from).unit * 1), to)
	point.CFrame = CFrame.lookAt((CFrame.lookAt(to, from) * CFrame.new(0, 0, -2 - ((scale - 1) / 2))).p, to)
end

local Runtime = require(script.Parent.Parent.Runtime)

return Runtime.widget(function(from, to, color)
	local fallbackColor = Runtime.useState(BrickColor.random().Color)
	color = color or fallbackColor

	if typeof(from) == "Instance" then
		if from:IsA("BasePart") then
			from = from.CFrame
		elseif from:IsA("Attachment") then
			from = from.WorldCFrame
		end

		if to ~= nil then
			from = from.p
		end
	end

	if typeof(to) == "Instance" then
		if to:IsA("BasePart") then
			to = to.Position
		elseif to:IsA("Attachment") then
			to = to.WorldPosition
		end
	end

	if typeof(from) == "CFrame" and to == nil then
		local look = from.lookVector
		to = from.p
		from = to + (look * -10)
	end

	if to == nil then
		to = from
		from = to + Vector3.new(0, 10, 0)
	end

	assert(typeof(from) == "Vector3" and typeof(to) == "Vector3", "Passed parameters are of invalid types")

	local refs = Runtime.useInstance(function(ref)
		local container = Instance.new("Folder")
		container.Name = "Arrow"

		ref.folder = container

		arrow("front", container, 1, color, 1)
		arrow("back", container, 2, Color3.new(0, 0, 0), -1)

		return container
	end)

	local folder = refs.folder

	update(folder.frontBody, folder.frontPoint, from, to, 1)
	update(folder.backBody, folder.backPoint, from, to, 1.4)

	folder.frontBody.Color3 = color
	folder.frontPoint.Color3 = color
end)
