Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Hi my gui is not opening when i text the command on the chat. How i can fix ?Pls

My code is

local main = script.Parent.main
local Players = game:GetService("Players")
local AdminFrame = script.Parent.main
local ennablecommand = ";admin"

Players.PlayerAdded:Connect(function(plr)
	print("Test")
	plr.Chatted:Connect(function(msg)
	if msg:lower() == "teste" then
		AdminFrame.Visible = true
	end
	end)
end)

My discord for more fast asks: Zypsoh#8546

1 comment

0

iterate through the players using for i,v in pairs(Players:GetChildren()) do and then to reference the players you would use v instead of plr

1 answer

✓ Accepted answer

You can't use the PlayerAdded event in a script running on the client. As such, in a LocalScript, you can use LocalPlayer instead.

Put this into a LocalScript:

local main = script.Parent.main
local plr = game.Players.LocalPlayer
local AdminFrame = script.Parent.main
local ennablecommand = ";admin"


print("Test")
plr.Chatted:Connect(function(msg)
	if msg:lower() == "teste" then
	    AdminFrame.Visible = true
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.