Is there anyway to connect the dots on a radar chart in Roblox? sorry its hard to explain but like this https://prnt.sc/hwaa5u
✓ ANSWER ACCEPTED
Is there anyway to do this? (connecting radar chart)
1 answer
✓ Accepted answer
If you know the location of the dots (you can get this from any GuiObject with the AbsolutePosition property), then you can use this:
local function DistanceBetweenPoints(PointA, PointB)
return math.sqrt( math.pow(PointB.X-PointA.X, 2) + math.pow(PointB.Y-PointA.Y, 2) )
end
local function AverageBetweenPoints(PointA, PointB)
return (PointA.X + PointB.X) * 0.5, (PointA.Y + PointB.Y) * 0.5
end
local function SlopeBetweenPoints(PointA, PointB)
return (PointB.Y - PointA.Y) / (PointB.X - PointA.X)
end
local function AngleBetweenPoints(PointA, PointB)
return -math.atan( 1 / SlopeBetweenPoints(PointA, PointB) )
end
local function CreateLineBetweenPoints(PointA, PointB, Thickness, ExtraProps)
local LineLength = DistanceBetweenPoints(PointA, PointB)
local LineCenterX, LineCenterY = AverageBetweenPoints(PointA, PointB)
local LinePositionX = LineCenterX
local LinePositionY = LineCenterY - math.abs((PointA.Y-PointB.Y) * 0.5)
local LineAngle = AngleBetweenPoints(PointA, PointB)
local Line = Instance.new("Frame")
Line.Size = UDim2.new(0, Thickness, 0, LineLength)
Line.Position = UDim2.new(0, LinePositionX , 0, LinePositionY)
Line.Rotation = math.deg(LineAngle)
for Property, Value in pairs(ExtraProps) do
Line[Property] = Value
end
return Line
end
-- Creates a vertical line
local MyLineThickness = 2
local MyLineExtraProperties =
{
Name = "MyLine",
BorderSizePixel = 0,
BackgroundColor3 = Color3.new(1, 0, 0)
}
local DotAPoint = Vector2.new(100, -50)
local DotBPoint = Vector2.new(100, 20)
local MyLine = CreateLineBetweenPoints(
DotAPoint, DotBPoint, MyLineThickness, MyLineExtraProperties)
MyLine.Parent = game.Players.LocalPlayer.PlayerGui.ScreenGui
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Thank you so much