Hello, im currently trying to figure out how to make my global messaging system display 1, then wait then display the next if there are more than 1 messages in the queue to be displayed. I just spent like 2 hours coding a system but ended up failing miserably. Can anyone help me?
Base code:
local whitelist = {
411491496,
}
local messageQueue = {}
local messageDebounce = false
local function main()
game.Players.PlayerAdded:Connect(function(player)
local val = Instance.new("BoolValue")
val.Name = "GlobalMessagingPerms"
val.Value = false
val.Parent = player
for i,v in pairs(whitelist) do
if player.UserId == v then
val.Value = true
break
end
end
if not val.Value then
game.ReplicatedStorage.GlobalMessaging:FireClient(player,"Remove Input GUI","Null")
end
end)
game.ReplicatedStorage.GlobalMessaging.OnServerEvent:Connect(function(player,action,message)
if action == "Send Message Sever" and player.GlobalMessagingPerms.Value then
table.insert(messageQueue,message)
end
end)
local function displayNum()
messageDebounce = true
game.ReplicatedStorage.GlobalMessaging:FireAllClients("Display Message", messageQueue[1])
table.remove(messageQueue,1)
wait(8)
messageDebounce = true
end
end
main()
This code is not functional ATM because i just deleted part of the attempted queue system, but before there was a queue system i just displayed what was being requested whenever something got requested, which resulted in a lot of things overriding and causing issues. By the way, the animation takes 7 seconds thats why I have the wait(8)