If the player has stated the command, the GUI opens - issue

I’m currently having an issue with the script that is supposed to execute a GUI when the command is used in the chat by anyone. I’m attempting to find all of the solutions, but they don’t seem to function for me as intended to. If I could be offered some assistance, it’d be appreciated to be taught something new from an experienced scripter.

Aim for this script:

  • When a player states “.info me”, it privately shows them the GUI (which is located in StarterGui).

Here’s my current script:

plr = game.Players.LocalPlayer
aim = game:GetService("StarterGui").ScreenGui:Clone().Parent == plr.playerGui
plr.Chatted:Connect(function(message)
	if message == ".info me" then
	aim = true
	aim.Frame.Visible = true
	   
		
	end
end)

Is there a line that I’m doing inaccurately? If so, please inform me as I’d like to learn the basics.

A few things. StarterGui is a container that replicates the GUI into a player’s container at the start of the game. You should use replicated storage, then copy it into the playerGUI last. Once it is in there, it can no longer be modified on the server. That means you should make it visible before copying it over. Also aim = true makes no sense. You should just use the clone().Parent = plr.PlayerGui and it will do just that.

The aim variable checks to see if the GUI is a child of PlayerGui, but there’s no need to do that because any gui in StaterGui automatically clones to the PlayerGui. So you can just do:

local plr = game.Players.LocalPlayer
local aim = game.Players.LocalPlayer.PlayerGui.ScreenGui
plr.Chatted:Connect(function(message)
	if message == ".info me" then
	aim.Frame.Visible = true
	   
		
	end
end)

I believe you want to change visibility before replicating to PlayerGui as it won’t replicate once in that container and would require a remote event.

Edit: Nevermind it is a local script.

Alright, so I do understand that I’d need to change the GetService line, but I don’t understand the rest of the statement. I’ve placed the ScreenGui in the ReplicatedStorage, but when I still attempt to execute the command, it doesn’t function as intended to. I’m doing something inaccurate?

Also, my script is held in a LocalScript and is found in the Workplace.

plr = game:GetService("Players").LocalPlayer
aim = plr.PlayerGui.ScreenGui --Change ScreenGui to something unique
plr.Chatted:Connect(function(message)
	if message == ".info me" then
	aim.Frame.Visible = true
	end
end)

And when I mean change to something unique, I mean change the actual ScreenGui to something that is not called that, and then update the directory so it is plr.PlayerGui.NewName.

Also leave the GUI in StarterGui instead of ReplicatedStorage-- it is easier for you.

1 Like

Hold on, does the frame has to be a frame? Since mine is an imagelabel.

You can do .Visible on an image label. Just make sure the image’s transparency is 0.

It doesn’t seem to operate as intended. I’ve inserted the LocalScript in the Workspace, I’ve replaced my ScreenGui (identified as “UserDetails”) and replaced the frame’s name with “Main”.

image
This is my code I’ve entered in the LocalScript:

aim = plr.PlayerGui.UserDetails 
plr.Chatted:Connect(function(message)
	if message == ".info me" then
	aim.Main.Visible = true
	end
end)

This is how it should look like from point of view:

LocalScripts don’t run in the Workspace.

Yea make sure that script is in StarterPlayerScripts

Alright, this has been solved, thank you for assisting!

Even though it’s now resolved, remind yourself to lowercase everything, since that script won’t work if I type .Info me or .iNfO mE