Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How to Fix Line Graph Generating Script? [closed]

Asked by
Benbebop 1049 Moderation Voter
5 years ago
Edited 5 years ago

I made a script that gets ping, now I want to make a line graph that shows that information. But the lines do not match up at all with the plots.

Heres the script:

01local TweenService = game:GetService("TweenService")
02local LastPlot = Vector2.new(0,0)
03 
04script.Parent.Ping.Changed:Connect(function()
05    local CurrentPlot = Vector2.new(1, 1 - (script.Parent.Ping.Value / 500))
06    local DataPoint = script.LineSegment:Clone()
07    DataPoint.Position = UDim2.new(1, 0, 1 - (script.Parent.Ping.Value / 500), 0)
08    DataPoint.Parent = script.Parent.Plots
09 
10    local LineSegment = script.LineSegment:Clone()
11    LineSegment.AnchorPoint = Vector2.new(0,0)
12    LineSegment.Position = UDim2.new(LastPlot.X, 0, LastPlot.Y, 0)
13    LineSegment.Size = UDim2.new((CurrentPlot - LastPlot).Magnitude, 0, 0, 1)
14    LineSegment.Rotation = 180/math.pi*math.atan((CurrentPlot.Y - LastPlot.Y)/(CurrentPlot.X - LastPlot.X))
15    LineSegment.Parent = script.Parent.Plots
View all 29 lines...

Sorry if this is a mess you only need to worry about lines 11-16

Defiantly a problem with my equation on line 13 but I'm not sure what I did wrong.

(CurrentPlot - LastPlot).Magnitude

Here im trying to get the distance (In scale not offset) between the two Vector2s.

Here is the Explorer

Here is the Results

I know there is a problem with the tweening and destroying but I can fix that myself

0
Maybe get rid of the inner set of parenthesis? If you just have one for the udim thing, it may work, but that is all I can think of since I am not good at this sort of stuff. Phyrixia 51 — 4y
0
@Phyrixia I already found a solution for this awhile ago, thanks none the less. Benbebop 1049 — 4y

Locked by Leamir

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?