Gui Script not working!

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to fix my gui script so that when the gui button is clicked, the target ui will become visible.

  2. What is the issue? The script is not working.

  3. What solutions have you tried so far? Looking on devforum, repeatedly checking heirachy of object in the explorer tab.

Screenshot 2024-05-13 190657

Here is the code:

local Button = script.Parent
local TargetUI = game.StarterGui.Ysup.TextLabel

Button.MouseButton1Click:Connect(function()
	print("the button works")

	if TargetUI then
		print("TargetUI found")
		TargetUI.Visible = true
	else
		warn("TargetUI not found!")
	end
end)

Thanks, Max.

You are editing the startergui. not playergui. playergui can be found in game.players[PlayerName].PlayerGui

I have tried and I am kind of not sure how to do it, could you show me an example and I can work with that.

Change the script you have to a localscript and you could do

local PlrGui = game.Players.Localplayer.PlayerGui
local TargetUi = PlrGui.Ysup
local Button = script.Parent

Button.MouseButton1Click:connect(function()
TargetUi.Visible = true
end)

it says: Localplayer is not a valid member of Players “Players” in the output, mabye try something like PlayerAdded .

Im not sure exactly how localplayer is spellt. maybe its “LocalPlayer” or “localplayer”?
also make sure that you have done it in a localscript

1 Like

ok lemme try, I do have it in a local script

Oh god thank you so much, I edited the script to work a bit and it is going completely fine, thanks for helping alot.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.