How i can fill Random figures generated by my script

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    I want to fill the figure generated by my script.

  2. What is the issue? i dont know how to do it

  3. What solutions have you tried so far? Looking in Devforum and chat gpt :tired_face:

image

image

I want to fill the figures generated by my script. The script itself is working, I just need an answer on how to fill the figures.

Code:

local CenterPosition = UDim2.new(0.5, 0, 0.5, 0)
local Radius = 150 
local NumAxes = 5 


local gui = Instance.new("ScreenGui")
gui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")


local frame = Instance.new("Frame")
frame.Size = UDim2.new(0, Radius * 2, 0, Radius * 2)
frame.Position = CenterPosition - UDim2.new(0, Radius, 0, Radius)
frame.BackgroundTransparency = 1

frame.Parent = gui

local p = script.CHART:Clone()
p.Parent = frame



for i = 1, NumAxes do
	local angle = math.rad((i - 1) * (360 / NumAxes))
	local x = math.sin(angle) * Radius
	local y = -math.cos(angle) * Radius

	local axis = Instance.new("Frame")
	axis.Size = UDim2.new(0, 1, 0, Radius)
	axis.Position = UDim2.new(0.5, x, 0.5, y)
	axis.BackgroundColor3 = Color3.new(0, 0, 0)
	axis.BackgroundTransparency = 1
	axis.BorderSizePixel = 0
	axis.Parent = frame
end


local statLabels = {
	"Power",
	"Speed",
	"Trick",
	"Recovery",
	"Defense"
}

for i = 1, NumAxes do
	local angle = math.rad((i - 1) * (360 / NumAxes))
	local x = math.sin(angle) * (Radius + 20)
	local y = -math.cos(angle) * (Radius + 20)

	local label = Instance.new("TextLabel")
	label.Size = UDim2.new(0, 100, 0, 30)
	label.Position = UDim2.new(0.5, x, 0.5, y)
	label.AnchorPoint = Vector2.new(0.5, 0.5)
	label.Text = statLabels[i]
	label.TextColor3 = Color3.new(0, 0, 0)
	label.BackgroundTransparency = 1
	label.Parent = frame
end




local guiInset = game:GetService("GuiService"):GetGuiInset()
function drawPath(P1, P2,parent)
	local Line = Instance.new("Frame")

	local Size = workspace.CurrentCamera.ViewportSize - guiInset

	local startPoint = Vector2.new(P1.X.Scale, P1.Y.Scale)*Size + Vector2.new(P1.X.Offset, P1.Y.Offset)
	local endPoint = Vector2.new(P2.X.Scale, P2.Y.Scale)*Size + Vector2.new(P2.X.Offset, P2.Y.Offset)

	local magnitude = (startPoint - endPoint).Magnitude
	local center = (startPoint + endPoint) / 2

	Line.Size = UDim2.new(0, magnitude, 0, 5)
	Line.Position = UDim2.fromOffset(center.X, center.Y)
	Line.Rotation = math.atan2(endPoint.Y - startPoint.Y, endPoint.X - startPoint.X) * (180 / math.pi)
	Line.Name = "Linea"
	Line.AnchorPoint = Vector2.new(0.5, 0.5)
	Line.Parent = parent
end




local function UpdateRadarChart(values)
	local dataPoints = {}
	for i = 1, NumAxes do
		
		
		local angle = math.rad((i - 1) * (360 / NumAxes))
		local value = math.clamp(values[i], 0, 10) 
		local radius = Radius * (value / 10) 
	
		local x = math.sin(angle) * radius
		local y = -math.cos(angle) * radius


		local dataPoint = frame:FindFirstChild("DataPoint_" .. i)
		
		if dataPoint then
			dataPoint:TweenPosition(UDim2.new(0.5, x, 0.5, y), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 0.2, true)
			
		else
			dataPoint = Instance.new("Frame")
			dataPoint.Name = "DataPoint_" .. i
			dataPoint.Size = UDim2.new(0, 5, 0, 5)
			dataPoint.Position = UDim2.new(0.5, x, 0.5, y)
			dataPoint.AnchorPoint = Vector2.new(0.5, 0.5)
			dataPoint.BackgroundColor3 = Color3.new(1, 0, 0)
			dataPoint.BorderSizePixel = 0
			dataPoint.Parent = frame
			
		end
		table.insert(dataPoints, dataPoint)
		
	end
	for i,v in pairs(frame.Parent:GetChildren()) do
		if v.Name == "Linea" then
			v:Destroy()
		end
	end
	for i = 1, NumAxes do
		local dataPoint = frame:FindFirstChild("DataPoint_" .. i)
		local laststat
		if i == 5 then
			laststat = 1
		else
			laststat = i + 1
		end
		print(laststat)
		coroutine.wrap(function()
			if dataPoint then
				task.wait(.2)
			end
			local lastdatapoint = frame:FindFirstChild("DataPoint_" .. laststat)
			drawPath(dataPoint.Position,lastdatapoint.Position,frame.Parent)
		end)()
		
	end
end

local newValues = {1, 1, 1, 1, 1} 
UpdateRadarChart(newValues)
1 Like