Image label not being visible after character reset

Description:

I made a script which when you executed a command, the target’s imagelabel will be visible. But when you reset, it makes the visibility back to false again.

Script:

local koscommand = "kos"
local revokekoscommand = "revoke"

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		player.Chatted:Connect(function(msg)
			local SplitString = string.split(msg, " ")
			if SplitString[1] == koscommand then
				for _, players in pairs(game.Players:GetPlayers()) do
					local target = players.Name
					for i = 1, #target do
						if SplitString[2] == string.sub(target, 1, i) then
							game.Workspace:FindFirstChild(target).Head.OverheadIcon2.KoS.Visible = true
						end
					end
				end
			elseif SplitString[1] == revokekoscommand and SplitString[2] == koscommand then
				for _, players in pairs(game.Players:GetPlayers()) do
					local target = players.Name
					for i = 1, #target do
						if SplitString[3] == string.sub(target, 1, i) then
							game.Workspace:FindFirstChild(target).Head.OverheadIcon2.KoS.Visible = false
						end
					end
				end
			end
		end)
	end)
end)


(Sorry if my script wasn’t that good)

1 Like

Set the GUI’s “ResetOnSpawn” property to false and it should be fixed.

Mhm I did, but somehow still sets the imagelabel visibility to false. .-.

You should actually set it to true, so it resets and becomes visible again after reset. Don’t quote me on this

It’s a SurfaceGui which is parented to the player’s character’s head.

I see. Make a variable in the PlayerAdded event which stores whether or not the frame should be visible. Then, when a character is added if the variable is true, make the frame visible.