So after fixing infinite yield issues, I’m now faced with another issue. For some reason, whenever I insert and set up the model (via script), I keep facing the issue of one of the essential scripts’ PlayerAdded event not firing, and I’m unsure what the reason for this is. I have an auto updater script which is linked to this (I redesigned this after the last issue by the way), and I feel its something to do with the script running after the player joins. Help? I literally have no idea what the cause of this is.
Auto Updater Script
local insertService = game:GetService("InsertService")
local id = 6408603034
local function UnpackModel(Model)
for index, Item in pairs(Model:GetChildren()) do
Item.Parent = Model.Parent
end
Model:Destroy()
end
local Model
local success, errormsg = pcall(function()
local latestVer = insertService:GetLatestAssetVersionAsync(id)
Model = insertService:LoadAssetVersion(latestVer)
end)
if Model ~= nil then
local NewModel = Model["J+ Admin"]
NewModel.Parent = workspace
NewModel.Instructions:Destroy()
for index, item in pairs(NewModel:GetChildren()) do
if item:IsA("Model") then
item.Parent = game:GetService(item.Name)
UnpackModel(item)
end
end
Model:Destroy()
end
script.Parent:Destroy()
Main Handler Script (The One With The Broken PlayerAdded Event
--//Variables//--
local commandsModule =require(game.ServerStorage:WaitForChild("commands", 10))
local modModule = require(game.ServerStorage:WaitForChild("moderationDataCommands"))
local ChatLogsTable = {}
local httpService = game:GetService("HttpService")
local coolDownAmount = 360 --One request from the player 6 minutes
local textService = game:GetService("TextService")
local groupId = 7895196
local requiredRank = 253
local J_AdminBugReportWebhook = "https://discord.com/api/webhooks/812712579008430101/VDjyQ8YRcQR874svf_PyK5ARdS47FTDF1m989Kg5fszVGP8cbKKGma2wdccLW8_FvOs0"
--//PlayerAdded Handler//--
game.Players.PlayerAdded:Connect(function(Player)
print("Recieved Event")
modModule.PresetData(Player)
modModule.OverwriteData()
print("Instanced")
local isLoggedIn = Instance.new("BoolValue")
local isWaiting = Instance.new("BoolValue")
isWaiting.Name = "IsWaiting"
isWaiting.Parent = Player
isLoggedIn.Name = "Verified"
isLoggedIn.Parent = Player
print(isLoggedIn.Parent.Name)
if modModule.CheckBan(Player) then
print("Configured Datastores")
local warns = Instance.new("IntValue")
warns.Parent = Player
warns.Name = "Warns"
game.ReplicatedStorage.sendCommands:FireClient(Player,commandsModule)
game.ReplicatedStorage.refreshPlayers:FireClient(Player)
print("Fired Table And Instanced All Values!")
Player.Chatted:Connect(function(Chat)
table.insert(ChatLogsTable, #ChatLogsTable+1, Player.Name..": "..Chat)
end)
else
Player:Kick("Sorry "..Player.Name.." But You Are Still Banned, If You Want To Be Unbanned then appeal to an admin")
end
end)
--//Loop Saving Moderation Data//--
while wait(30) do
modModule.SaveData()
end
--//On Server Event//--
game:GetService("ReplicatedStorage").updateLoggedInVal.OnServerEvent:Connect(function(Player, LoggedIn)
if LoggedIn then
Player.Verified.Value = true
print("Set!")
end
end)
--//Verify Player Handler//--
function VerifyAndReturn(Player)
if Player:GetRankInGroup(groupId) >= requiredRank then
return true
else
local isInModule
for index, Id in pairs(require(game.ServerStorage.allowedIDs)) do
if Player.UserId == Id then
isInModule = true
end
end
if not isInModule then
return false
else
return
end
end
end
game:GetService("ReplicatedStorage").isVerifiedCallback.OnServerInvoke = VerifyAndReturn
--//Chat Log Returner//--
function GetAndReturnChatLogs()
return ChatLogsTable
end
--//Moderation Handler//--
function ReturnModerationsForPlayer(Player)
return modModule["Player-"..Player.UserId]
end
game:GetService("ReplicatedStorage").getDatastoredModerations.OnServerInvoke = ReturnModerationsForPlayer
--//Player-Removing Handler//--
game.Players.PlayerRemoving:Connect(function(Player)
game.ReplicatedStorage.refreshPlayers:FireAllClients()
end)
--//Bug Report Manager//--
game.ReplicatedStorage.sendHTTP.OnServerEvent:Connect(function(Player, sentText)
if not Player.IsWaiting.Value then
local filteredString = textService:FilterStringAsync(sentText, Player.UserId)
if filteredString then
local resultString = filteredString:GetNonChatStringForUserAsync(Player.UserId)
print("Player "..Player.Name.." Sent: "..resultString)
local Data = {
["content"] = "**J+ Admin Bug Report received!**\n\n*Username:* `"..Player.Name.."`\n*Feedback:*\n`"..resultString.."`"
}
Data = httpService:JSONEncode(Data)
Player.IsWaiting.Value = true
httpService:PostAsync(J_AdminBugReportWebhook, Data)
wait(coolDownAmount)
Player.IsWaiting.Value = false
end
end
end)