Why can't I make this image visible?

Hello, I’ve been trying to find a way to make this image visible for the past two hours and cannot for the life of me figure it out. There are no errors in the output, what am I doing wrong?

The following code is in a regular Script:

local eggPart = script.Parent
local toggle = false
local amount = 1
local eggCover = game.StarterGui.CollectionGUI.EggMainFrame.ScrollingFrame.Egg1Cover

eggPart.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") ~= nil and not toggle then
		toggle = true
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		local leaderboard = player:FindFirstChild("EggLeaderboard")
		local eggs = leaderboard.Eggs
		if eggs.Value < 20 then
			eggs.Value = eggs.Value + amount
			wait(1)
			eggCover.Visible = true --This is the part not working, it runs the rest of the code.
			wait()
			eggPart.Transparency = 1
			wait(5)
			eggPart.Transparency = 0
		end
	end
end)

Screenshots

Location of Egg1Cover Image

imageLocation

Location of eggPart in the Workspace

EggLocation

Extra Information:
– The image’s visible property is set to False by default
– The image’s Zindex is 2 (not sure if you really needed to know that)

The StarterGui is only replicated once to playergui, eggCover should be referenced from the playergui not the StarterGui. However, keep in mind you can’t just access the localplayer in a normal script , which means you need to use the player variable you defined in your touched event to modify something in the playergui. Player>PlayerGui

As a good recommendation instead of modifying the gui directly from server (which it appears to be what you are doing currently) you can set up a remote event to tell the client to show the gui .

1 Like

Alright thanks, I will try that out now.