GUI Open by Value

I’m trying to make a GUI that when you click a button it sets a Value in the workspace to your username and then makes a GUI frame visible. Everything I’ve tried so far doesn’t work, I’ll pop the scripts below.

BUTTON SCRIPT

script.Parent.MouseButton1Click:Connect(function(Player)
	if game.Workspace.HostValue.Value == "None" then
		game.Workspace.HostValue.Value = Player.Name
		game.ReplicatedStorage.HostEvent:FireClient(Player)
	 end
end)

GUI FRAME SCRIPT


local Event = game.ReplicatedStorage.HostEvent
Event.OnClientEvent:Connect(function(player)
	script.Parent.Visible = false
end)

This is the error:

Any help is appreciated!

MouseButton1Click event doesnt return anything, Player is equal to nil

Last time I did something like this, I got the same error. Its because MouseButton1Click doesn’t work like PlayerAdded. PlayerAdded gives a player value, I’m not sure how MouseClick works but I do know you cannot get a player from that function, try getting the localplayers name. It’s a client script so just do game.Players.LocalPlayer.Name… etc. I also don’t see why you need a remote for this.

The Remove Event opens the GUI. I’ve changed it so it now changes the value to the player name but it still doesn’t open the GUI.

^^ I’m trying to make a button only visible to the PlayerName of the value.

I’ve tried this but it doesn’t work:

if game.Players.LocalPlayer.Name == game.Workspace.HostValue then 
		script.Parent.Visible = true
 end

Would it be?

if game.Players.LocalPlayer.Name == game.Workspace.HostValue.Value then 
		script.Parent.Visible = true
 end

That’s the same as the script above that I said didn’t work.


Well it seems like you forgot to add .Value at the end tho

1 Like