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

Trying to make a command that gives you a Gui. How do I fix my script?

I was trying to make a command that if the player is an admin and they say the command, they obtain the gui. The problem is, the gui is not being given once you say the keyword, and the output wont speak. The script is placed in ServerScriptService, and its child is the ScreenGui. Heres the script:

local admins = {"Prxticles"}

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		if player.Name == admins then
			if message == "/e leaf" then
				script.Leaf:Clone().Parent = player.PlayerGui
			end
		end
	end)
end)

1 answer

Since admins is a table, a player's name can't equal that.

So I'd run a loop to check it

local admins = {"Prxticles"}

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        local isAdmin = false
	for i, v in pairs(admins) do --runs through all entries in the admins table
		if player.Name == v then
			isAdmin = true --they're an admin!
			break --end the loop
		end
	end
	if message == "/e leaf" and isAdmin then
		script.Leaf:Clone().Parent = player.PlayerGui
	end
    end)
end)


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