I am currently attempting to make an activity logging system using the TrelloAPI. However, the PlayerAdded event does not seem to run.
I have tried putting a print above the Initalize() function and it does print, but when I put it inside the function, it does not run. Any reasons as to why this does not work?
--// SERVICES
local ServerScriptService = game:GetService("ServerScriptService")
local Players = game:GetService("Players")
--// VARIABLES
local config = ServerScriptService:WaitForChild("TrelloConfig")
local TrelloAPI = require(ServerScriptService:WaitForChild("TrelloAPI"))
local GroupId = 5303719
local TA = config:WaitForChild("TA")
local RS = config:WaitForChild("RestaurantSupervisor")
local RM = config:WaitForChild("RestaurantManager")
local BoardName = config:WaitForChild("BoardName")
local TAListName = config:WaitForChild("TAListName")
local RSListName = config:WaitForChild("RSListName")
--//Initialize TrelloAPI
local BoardID = TrelloAPI:GetBoardID(BoardName.Value)
local TAList = TrelloAPI:GetListID(TAListName.Value,BoardID)
local RSList = TrelloAPI:GetListID(TAListName.Value,BoardID)
--//FUNCTIONS
function Format(Int)
return string.format("%02i", Int)
end
function convertToHMS(Seconds)
local Minutes = (Seconds - Seconds%60)/60
Seconds = Seconds - Minutes*60
local Hours = (Minutes - Minutes%60)/60
Minutes = Minutes - Hours*60
return Format(Hours)..":"..Format(Minutes)..":"..Format(Seconds)
end
function Log(player) -- Log it
local rank = player:GetRankInGroup(GroupId)
local TimeInGame = player:FindFirstChild("TimeInGame")
local HMS = convertToHMS(TimeInGame.Value)
if rank == TA.Value then
local NewCard = TrelloAPI:AddCard(player.Name.." | "..HMS,"",TAList)
elseif rank == RS.Value then
local NewCard = TrelloAPI:AddCard(player.Name.." | "..HMS,"",RSList)
end
end
function Count(player) -- Start the timer!
while wait(1) do
local TimeInGame = player:FindFirstChild("TimeInGame")
TimeInGame.Value = TimeInGame.Value + 1
end
end
function Initalize(player)
if player:GetRankInGroup(GroupId) >= TA.Value then
local counter = Instance.new("IntValue")
local variables = player:WaitForChild("Variables")
counter.Value = 0
counter.Name = "TimeInGame"
counter.Parent = variables
Count(player)
end
end
Players.PlayerAdded:Connect(Initalize)
Players.PlayerRemoving:Connect(Log)