Warn command won't display images

The title says it all, my warn command won’t display the images used to display how many warnings you have. (e.g W1, W2, W3)

It does kick you if you have the max amount of warnings, (which is 3 in my case) but none of the images show to actually display the amount of warnings the user has.

Script
local GroupID = 4607825
local MinimumRankToUseCommands = 240

game.Players.PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(Message)
		local SplitMessage = Message:split(" ")
		if SplitMessage[1] == "!warn" and Player:GetRankInGroup(GroupID) >= MinimumRankToUseCommands then
			local NameOfPlayerToWarn = SplitMessage[2]
			local PlayerToWarn = game.Players:FindFirstChild(NameOfPlayerToWarn)

			local WarningGUI = PlayerToWarn.Character.Head.GUI -- Apperently, this line is the problem. :/
			local CurrentWarnings = WarningGUI.Warnings

			CurrentWarnings.Value = CurrentWarnings.Value + 1
			WarningGUI.Frame.WarningImgs.W1.Visible = true
			print("Player warned!")

			CurrentWarnings.Value = CurrentWarnings.Value + 2
			WarningGUI.Frame.WarningImgs.W1.Visible = false
			WarningGUI.Frame.WarningImgs.W1.Visible = true
			print("Player warned!")

			CurrentWarnings.Value = CurrentWarnings.Value + 3
			WarningGUI.Frame.WarningImgs.W2.Visible = false
			WarningGUI.Frame.WarningImgs.W3.Visible = true
			print("Player warned!")

			if CurrentWarnings.Value >= 3 then
				PlayerToWarn:Kick("You've reached the maximum number of warnings and have been kicked from the server.")
			end
		end
	end)
end)

I’m assuming this is a server script?

You are correct, it’s a server script.

You need to use a remote event then, so try doing this:
Create a RemoteEvent inside of ReplicatedStorage, name it “DisplayWarnImage” or however you’d like to name it. From the server script instead of trying to make the warning visible do this,

local remote = game.ReplicatedStorage:WaitForChild('DisplayWarnImage')
remote:FireClient(PlayerThatIsGettingWarned)

After that create a LocalScript inside of StarterGui and do this,

local player = game.Players.LocalPlayer
local remote = game.ReplicatedStorage:WaitForChild('DisplayWarnImage')
local warningsHolder = player.PlayerGui:WaitForChild('TheGuiWhereYouStoreWarningImages')

remote.OnClientEvent:Connect(function()
   warningHolder.WarningImage.Visible = true
end)

Never edit gui from a server script. Also I believe the reason it didn’t work was because you didn’t access the player’s gui instead the StarterGui but I could be wrong about that.