I am trying to make a system to show the data from an A-Chassis script on a website. I have the HTTP working and am getting the data from the car now. I have some things set up through Attributes which are showing properly, but when I go to print the tire wear it prints 1 even if it is not 1. I have no errors and all the prints are working (checkpoints you will see in script).
--Variables
local plr = game.Players
--local ThisPlr = plr.LocalPlayer
local event = game.ReplicatedStorage.Event
local Seat = workspace.Screen1.SurfaceGui.Seat
local http = game:GetService("HttpService")
local recentData = {}
function sendData(data, uid)
local finalRes = http:JSONEncode(data)
--print("verdict: " .. tostring(not (recentData[uid] == finalRes)))
if(not (recentData[uid] == finalRes)) then
local ping = http:PostAsync("", finalRes)
print("Sever Response: ", ping)
recentData[uid] = finalRes
end
end
function compileData(ThisPlr, plrGui)
print("Checkpoint z1")
local Name = ThisPlr.Name
local UI = plrGui
local Wheel = UI["[SS6] Dynamic Friction"].Tires
local Board = plrGui.Parent:FindFirstChild('Timing_Gui').Board.Timings.Name
print("Checkpoint z2: " .. Wheel.FL.First.Second.Position.Y.Scale)
--Tire data
local FL = Wheel.FL.First.Second.Position.Y.Scale
local FR = Wheel.FR.First.Second.Position.Y.Scale
local RL = Wheel.RL.First.Second.Position.Y.Scale
local RR = Wheel.RR.First.Second.Position.Y.Scale
------
--Speed data
local S1 = -1
local S2 = -1
local S3 = -1
local Best = -1
local Last = -1
local Pos = -1
local Player = -1
if UI.ORAHUD:FindFirstChild('Timing_Gui') then
S1 = Board.S1.Text
S2 = Board.S2.Text
S3 = Board.S3.Text
Best = Board.Best.Text
Last = Board.Last.Text
Pos = Board.Post.Text
Player = Board.Player.Text
else
end
--Other data
local Speed = UI.ORAHUD:FindFirstChild("Speed").Text
local Fuel = ThisPlr.PlayerGui:FindFirstChild("PitStop").TopFrame.SorterFrame.Gas.Fill.Size.Y.Scale
local energy = -1
local LMH = false
local Gear = UI.ORAHUD.Gear.Text
if UI.ORAHUD:FindFirstChild('Battery') then
local WordEnergy = UI.ORAHUD.Battery.percentage.Text
energy = tonumber(WordEnergy:sub(0,-2))
else
end
local CarGui = plrGui
local AccentColor = CarGui:GetAttribute("AccentColor")
local TeamId = CarGui:GetAttribute("TeamId")
local TeamName = CarGui:GetAttribute("TeamName")
local CarNumber = CarGui:GetAttribute("CarNumber")
local RaceName = game.ServerStorage.RaceName.Value
local leagueType = game.ServerStorage.leagueType.Value
------
print("Checkpoint z3")
--UID for identifying temporary data log (prevents sending of duplicate data)
local uid = TeamId .. tostring(CarNumber)
--Rationalize data
local ReadFL = tonumber((1-FL)*100)
local ReadFR = tonumber((1-FR)*100)
local ReadRL = tonumber((1-RL)*100)
local ReadRR = tonumber((1-RR)*100)
local ReadFuel = tonumber((Fuel)*100)
--Rounds all the numbers
local RoundFL = math.ceil(ReadFL)
local RoundFR = math.ceil(ReadFR)
local RoundRL = math.floor(ReadRL + 0.5)
local RoundRR = math.ceil(ReadRR)
local RoundFuel = math.ceil(ReadFuel)
print("Fuel: " .. Fuel)
local seat = Seat
local ReadSpeed = tostring(Speed)
local ReadGear = tostring(Gear)
local Name = ThisPlr.Name
local dataFmt = http:JSONEncode({
['carInfo'] = {
['teamId'] = TeamId,
['teamName'] = TeamName,
['name'] = Player,
['vehicleNumber'] = CarNumber,
['accentColor'] = AccentColor,
['vehiclePlace'] = Pos,
['previousLapTime'] = Last,
['sectors'] = {
['s1'] = S1,
['s2'] = S2,
['s3'] = S3
},
['tireData'] = {
['FL'] = RoundFL,
['FR'] = RoundFR,
['BL'] = RoundRL,
['BR'] = RoundRR
},
['fuel'] = RoundFuel,
['energy'] = energy
},
['eventInfo'] = {
['leagueType']= leagueType,
['raceName'] = RaceName
},
}
)
print("Checkpoint z4")
sendData(dataFmt, uid)
--Sends info to the server --
--event:FireServer(RoundFL, RoundFR, RoundRL, RoundRR, ReadSpeed, energy, ReadGear, RoundFuel, ThisPlr, LMH, CarId, TeamName, Name, TeamID)
------
end
function playerAdded(ThisPlr)
print(ThisPlr.Name)
print("Checkpoint O")
ThisPlr.CharacterAdded:Wait()
local char = ThisPlr.Character
local hum = char:WaitForChild('Humanoid')
print("Checkpoint J")
while wait() do
local goodToGo = true
print("Loop!")
while goodToGo do
print("Checkpoint H1")
local plrGui = ThisPlr.PlayerGui:WaitForChild('A-Chassis Interface')
print("Checkpoint H2")
print(plrGui.Name)
print("Checkpoint H3")
if(plrGui == nil) then
print("Checkpoint N")
goodToGo = false
break
end
print("Checkpoint H4")
if plrGui.Name == 'A-Chassis Interface' then
print("Checkpoint H5")
local myFavUDIM = plrGui:WaitForChild("[SS6] Dynamic Friction").Tires["FL"].First.Second
print("Checkpoint H6")
print(myFavUDIM.Position.Y.Scale)
print("Checkpoint H7")
compileData(ThisPlr, plrGui)
print("Checkpoint H8")
print("Checkpoint I")
if not hum.Sit then
plrGui:Remove()
end
else
print("Couldn't run!")
end
goodToGo = false
end
end
--print("Checkpoint M")
end
plr.PlayerAdded:Connect(playerAdded)
for i,v in next,game.Players:GetPlayers() do
print("Checkpoint L")
playerAdded(v)
end