How can I make a chat command where it changes the bool value of a specific section?

Hi there, I am trying to make a command where it can open and close the self check in for a specific class. I’ve tried everything but it doesn’t seem to change the boolvalue to true.

permission = {"UOME2K"}--Please keep my username is tere, :D

function check(player) 
	if table.maxn(permission)==0 then return true end
	for i = 1,#permission do   
		if string.lower(player.Name)==string.lower(permission[i]) then return true end 
	end 
	return false 
end 

local ecoboolvalue = game.Workspace.StarterGUI.SCI.SelfCheckInFrame.ecoInfo:FindFirstChild("EcoDecision")


if msg:lower() == "!openeconomy" then
	ecoboolvalue = true
	
elseif msg:lower() == "!closeeconomy" then
	ecoboolvalue = false
	-- If value of 'testBoolean' is false, this condition is executed
end

No matter how much I try, I can’t seem to change it’s boolvalue. I’m not entirely sure but I think the location of my boolvalue I entered is incorrect.

I think this is as simple as,

local ecoboolvalue = game.Workspace.StarterGUI.SCI.SelfCheckInFrame.ecoInfo:FindFirstChild("EcoDecision").Value

when adjusting a boolvalue you have to use a .Value
bool Value Used to hold a boolean value.

1 Like

Alright, Ill try and see if it works. Also how can I make it so that a certain rank in my group can only use the commands?

@56ytr56 It didn’t work, the economy class section was still closed.

also after looking at it our you trying to get the startergui?

1 Like

I don’t think so. I just need it to open a certain part in the GUI

safdfds

All I need is just the economy box to be enabled.

You need .Value to change the value of the instance

if msg:lower() == "!openeconomy" then

ecoboolvalue.Value = true

elseif msg:lower() == "!closeeconomy" then

ecoboolvalue.Value = false

-- If value of 'testBoolean' is false, this condition is executed

end
1 Like

is this a screen gui or a surface gui?, because if its a screen gui then i belive you have the wrong path to the bool.

1 Like

Ok Ill try to see if it works for me, Ill let you know if it works or not

1 Like

Yes that is indeed a ScreenGUI.

Hold on, I just realised I had Workspace in the path which was a mistake.

oh then try this.

local ecoboolvalue = player.PlayerGui.SCI.SelfCheckInFrame.ecoInfo:FindFirstChild("EcoDecision").Value

screen guis will only show if they are in the player gui

My gui is in starterGUI, there was no click function to open it…

This is what I got in the output. ServerScriptService.Script:11: attempt to index nil with ‘PlayerGui’

Im not trying to open the GUI, im trying to open this:

rererew rererew

hmm, what is the player variable, i was assuming it was the player instance

edit: about the player gui thing,
When a Players’ character respawns, the contents of their PlayerGui is emptied. Children of the StarterGui are then copied (along with their descendants) into the PlayerGui .

GUI objects such as ScreenGuis with their ResetOnSpawn property set to false will only be placed into each Player’s PlayerGui once and will not be deleted when the Player respawns.

What do you mean by the Player Variable?

oh when a player joins the game they get set a local player instance,

you can get this variable by

game:GetService("Players").PlayerAdded:Connect(function(player)
--the player in this case is the player instance          ^
end)

in a server script
and

local player = game:GetService("Players").LocalPlayer

in a client script parented to a part of the player (character/player gui)

Oh yeah I know that. My script is in ServerScriptService so it is the first script mentioned.

@56ytr56

the reason i was attempting to get the playergui was “The main storage object for 2D GuiObject displayed on the player’s screen. ScreenGuis will only be shown if parented to a player’s PlayerGui .”
also could you attempt to show me the explorer showing the path to the boolvalue, also is it a boolvalue or something else

edit: startergui replicats everything in itself and there desendants into playergui whenever the player dies/ joins