With Deferred Events enabled, my script only sometimes work:
local Players: Players = game:GetService("Players")
local HttpService: HttpService = game:GetService("HttpService")
local RandomService: Random = Random.new(...)
local ReplicatedStorage: ReplicatedStorage = game:GetService("ReplicatedStorage")
local Url: string = "Not telling ya"
Players.PlayerAdded:Connect(function(Player: Player)
local RandomColor = RandomService:NextInteger(0, 9999999) --string.sub(ColorPlus.RGBToHex(Color3.fromRGB(RandomService:NextInteger(0, 255), RandomService:NextInteger(0, 255), RandomService:NextInteger(0, 255))), 2, 7)
print(RandomColor)
local Content = HttpService:JSONEncode({
content = "",
embeds = {{
title = "**Player joined Tower Warriors! @"..Player.Name..":**",
description = "",
type = "rich",
color = RandomColor,
footer = {
text = "This account was created ".. os.date("%A, %B %d, %Y", os.time() - (Player.AccountAge * 86400))
}
}},
username = "@"..Player.Name.. " | Display name: ".. Player.DisplayName.. " | User ID: ".. Player.UserId
})
while true do
local Success: boolean, Error: string = pcall(function(...)
HttpService:PostAsync(Url, Content)
end)
if Success then
break
else
warn(Error)
end
end
end)
How would I be able to make deferred events work with this script, and possibly other scripts in the future?