Hi! I want to show a GUI to every player in the server after a player says ':m' in the chat. The GUI shows up but it only shows to one player, and after the the GUI disappears it shows up to the next player, and so on. Anyone has any idea why?
Script:
local Players = game:GetService("Players") local messageActivator = ":m" local MESSAGE = "" local MESSAGER = "" local function onPlayerChatted(player, message, recipient) if message:sub(1, messageActivator:len()):lower() == messageActivator:lower() then if message:sub(1, messageActivator:len()):lower() == messageActivator:lower() then MESSAGE = message:sub(messageActivator:len() + 1) MESSAGER = player.Name end end local function onPlayerAdded(player) player.Chatted:connect(function (...) onPlayerChatted(player, ...) for i,v in pairs(game.Players:GetPlayers()) do v.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("Message").Visible = true v.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("Message"):WaitForChild("Name").Text = MESSAGER v.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("Message"):WaitForChild("Message").Text = MESSAGE wait(3) v.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("Message").Visible = false end end) end for _, player in pairs(Players:GetPlayers()) do onPlayerAdded(player) end Players.PlayerAdded:Connect(onPlayerAdded)