Why is this not typing in chat?

I have no clue why this is not working I get no errors?

--Service's.

local ControllerService = game:GetService("ControllerService")

--"ControllerService" Instance's.

local RemoteEvent = ControllerService.RemoteEvent

--"MainGui" Instance.

local MainGui = game:GetService("Players").ScriptKiddXen.PlayerGui.MainGui

--"VICTORY_COUNT" And "DEFEAT_COUNT".

local VICTORY_COUNT = 0
local DEFEAT_COUNT = 0

--Checking If There Has Just Been A "VICTORY" Or "DEFEAT" When You Join.

if MainGui.EndMatch.Visible and MainGui.EndMatch.Result.Text == "VICTORY" then
   VICTORY_COUNT = VICTORY_COUNT + 1
   RemoteEvent:FireServer("chatted", "Good Game! (x" .. VICTORY_COUNT .. ")")
elseif MainGui.EndMatch.Result.Text == "DEFEAT" then
   DEFEAT_COUNT = DEFEAT_COUNT + 1
   RemoteEvent:FireServer("chatted", "Bad Game! (x" .. DEFEAT_COUNT .. ")")
end

--Checking If You Have Had A "VICTORY" Or "DEFEAT" And Adding 1 To "VICTORY_COUNT" Or "DEFEAT_COUNT" Everytime.

MainGui.EndMatch.Changed:Connect(function(Changed)
   if Changed == "Visible" and MainGui.EndMatch.Visible ~= false then
   	if MainGui.EndMatch.Result.Text == "VICTORY" then
   		VICTORY_COUNT = VICTORY_COUNT + 1
   		RemoteEvent:FireServer("chatted", "Good Game! (x" .. VICTORY_COUNT .. ")")
   	elseif MainGui.EndMatch.Result.Text == "DEFEAT" then
   		DEFEAT_COUNT = DEFEAT_COUNT + 1
   		RemoteEvent:FireServer("chatted", "Bad Game! (x" .. DEFEAT_COUNT .. ")")
   	end
   end
end)

What is supposed to be happening here? Please provide more information.

RemoteEvent:FireServer("chatted", "Bad Game! (x" .. DEFEAT_COUNT .. ")")

Types a chat message.

Gui =

image

I don’t see how you are typing a chat message by that , In that script you just firing a remote event with two string Parameters and changing the Victory Count , Can you be more specific?

It works when I manually change the visible value but it does not when I use a script

I dont see where you are changing the visibility and also the way you indexed the MainGui is not efficient you can get it from the Local Player.

I’m sure you’re getting sick of hearing this by now, but we really need more information. What is the other script handling the RemoteEvent? Where is Endmatch.Result.Text being set? Have you tried putting prints in a couple of spots to see where the script gets to?

Dont worry I just added a wait() and it owkrs xd