I made this script

click = false
highlight = false
local container = workspace:FindFirstChild("LocalBin")
if not container then
    container = Instance.new("Camera")
    container.Name = "LocalBin"
    container.Parent = workspace
end

script.Parent.ClickDetector.MouseClick:Connect(function(plar)
	print(plar.Name)
	if click == true and highlight == true then 
		container = workspace:FindFirstChild("LocalBin")
		container.Highlight:remove()
		plar.PlayerGui.CountryGUI.France.Visible = false
		click = false
		highlight = false
	else
		if container:FindFirstChild("Highlight") then return
			else
			click = true
			local Copy = script.Parent:Clone()
			Copy.HighlightScript:remove()	
			local Removal = game.ServerScriptService.REMOV:Clone()
			Removal.Parent = Copy
			Copy.Name = "Highlight"
			Copy.Parent = container
			Copy.Anchored = true
			Copy.CanCollide = false
			Copy.Position = script.Parent.Position
			Copy.BrickColor = BrickColor.new("Slime green")
			Copy.Transparency = .6
			Copy.Material = "Neon"
			plar.PlayerGui.CountryGUI.France.Visible = true
			end
	end
end)

local container = workspace:FindFirstChild("LocalBin")
if not container then
    container = Instance.new("Camera")
    container.Name = "LocalBin"
    container.Parent = workspace
end

It works perfectly in studio however in game this error occurs

CountryGUI is not a valid member of PlayerGui

Can anyone explain why this might be happening?

3 comments

0

If it's a server script, those cannot see within the PlayerGui object of the Player. Only localscripts can see its children.

0

Whenever something works in Studio, but not in game it's almost always an issue with crossing the Server/Client sides on Filtering Enabled.

0

That's FE, Studio's 'Play Solo' is experimental mode and doesn't apply FE, I'd suggest playing it in 'Local Server' test but I'd prefer to play the game(published) since it takes a lot of RAM when you run 'Local Server' (It runs new and separated Studio for Server and count of clients)