Make sure you use a LocalScript when using events in GUIs! While some events do work in normal scripts, others such as FocusLost do not! The reason it worked in Solo mode but not on a server is because in Solo, normal scripts are executed locally.
However, this does create another problem. You can not access another player's PlayerGui from a LocalScript. To solve this, try using a RemoteEvent.
In a LocalScript at the place where you had your script, put this:
1 | local focusLostRemoteEvent = script.Parent:WaitForChild( "Main" ):WaitForChild( "EnterText" ):WaitForChild( "FocusLostRemoteEvent" ) |
2 | script.Parent.Main.EnterText.FocusLost:connect( function () |
3 | focusLostRemoteEvent:FireServer() |
Then, replace the code you had in your normal Script with this:
01 | local focusLostRemoteEvent = Instance.new( "RemoteEvent" ) |
02 | focusLostRemoteEvent.Name = "FocusLostRemoteEvent" |
03 | focusLostRemoteEvent.Parent = script.Parent.Main.EnterText |
04 | focusLostRemoteEvent.OnServerEvent:connect( function () |
05 | if script.Parent.Main.EnterText.Text = = "[ Enter Text ]" then return end |
06 | if script.Parent.Main.EnterText.Text = = "" then return end |
07 | plyrs = game.Players:GetPlayers() |
09 | if not plyrs [ i ] .PlayerGui:FindFirstChild( "Comms" ) then |
10 | if not plyrs [ i ] .Backpack:FindFirstChild( "Virgo Comm" ) then return end |
11 | L = plyrs [ i ] .Backpack:FindFirstChild( "Virgo Comm" ) |
12 | L.Main.Messages.MSG 5. Text = L.Main.Messages.MSG 4. Text |
14 | L.Main.Messages.MSG 4. Text = L.Main.Messages.MSG 3. Text |
16 | L.Main.Messages.MSG 3. Text = L.Main.Messages.MSG 2. Text |
18 | L.Main.Messages.MSG 2. Text = L.Main.Messages.MSG 1. Text |
20 | L.Main.Messages.MSG 1. Text = "" |
22 | L.Main.Messages.MSG 1. Text = script.Parent.Parent.Parent.Name.. "// " ..game.Players:FindFirstChild(script.Parent.Parent.Parent.Name).PlayerGui.Comms.Main.EnterText.Text |
24 | L.Comms.Alert:Clone().Parent = L.Parent.Parent.Character.Head() |
25 | L.Parent.Parent.Character.Head.Alert.PlayOnRemove = true |
26 | L.Parent.Parent.Character.Head.Alert:remove() |
29 | C = plyrs [ i ] .PlayerGui:FindFirstChild( "Comms" ) |
30 | C.Main.Messages.MSG 5. Text = C.Main.Messages.MSG 4. Text |
32 | C.Main.Messages.MSG 4. Text = C.Main.Messages.MSG 3. Text |
34 | C.Main.Messages.MSG 3. Text = C.Main.Messages.MSG 2. Text |
36 | C.Main.Messages.MSG 2. Text = C.Main.Messages.MSG 1. Text |
38 | C.Main.Messages.MSG 1. Text = "" |
40 | C.Main.Messages.MSG 1. Text = script.Parent.Parent.Parent.Name.. "// " ..game.Players:FindFirstChild(script.Parent.Parent.Parent.Name).PlayerGui.Comms.Main.EnterText.Text |
44 | script.Parent.Main.EnterText.Text = "[ Enter Text ]" |
Doing that should fix the problem.