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)
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.
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”.
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)