I got a problem with my race system, basically i attempted making the race system dynamic witch presets information and the race handle them but when testing i found out all the for loops aren’t readed. Any fix?
local module = {}
local KnowRacesData = {
{
Name = "Off Road",
ExpirationTime = 120,
Laps = 3,
Reward = 3000,
}
}
function module:StartRace(race:string,players,vehicles)
local success,errorm = pcall(function()
if not race then
return
end
if not players then
warn("No players")
return
end
if not vehicles then
warn("No vehicles")
return
end
local racedata = false
for i,racedatav in KnowRacesData do
print(i,racedatav.Name)
if racedatav.Name == race then
racedata = i
print("Valid")
break
end
end
if not racedata then
warn("Unknow race given")
return
end
wait(4)
for t = 5,0,-1 do
for _, player in players do
game.ReplicatedStorage.RemoteEvents.SendRaceInformation:FireClient(player,"Race Countdown",t)
wait(1)
end
end
print("readed")
local GivableData = {
Name = racedata.Name,
Laps = racedata.Laps,
}
print("should print table")
for i,v in GivableData do
print(i,v)
end
for _,player in players do
print("should fire")
game.ReplicatedStorage.RemoteEvents.SendRaceInformation:FireClient(player,"Show Display",GivableData)
game.ReplicatedStorage.RemoteEvents.SendRaceInformation:FireClient(player,"Show Checkpoint",race)
end
end)
if success then
return module, true
else
return module, false,errorm
end
end
return module