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

Not sure what is wrong with this script, I've tried debugging?

The following script is not doing what it is intended to do, it is intended to check to see if a player is "banned", if they are banned text becomes visible saying "you are banned" if not it checks to see if the GUI menu is opened, if it is the GUI menu closes, if it isn't it opens. Below is the code.

local plyr = script.Parent.Parent.Parent.Parent.Parent
local Idea = script.Parent.Parent.IdeaGUI
local Button = script.Parent

function IdeaFunction()
	if plyr.Name == {"EmperorD"} then
		script.Parent.Parent.banned.Visible = true
	else if Idea.Visible == true then
		Idea.Visible = false
		Button.Text = "Open"
	else if Idea.Visible == false then
		Idea.Visible = true
		Button.Text = "Close"
	end
	end
	end
	end

script.Parent.MouseButton1Down:connect(IdeaFunction)

1 answer

You compare plyr.Name and {"EmperorD"}.

But plyr.Name is text, and {"EmporerD"} is a list. A list and text will never be equal, just based on them having different types. (One banana and one dog are never the same; we don't need to know anything more after knowing they are different kinds of things)


When you say ==, you're asking "are these the same".

Your intent for that line was "is plyr.Name contained within {"EmporerD"}* -- so that is what you should write.

function contains(list, element)
	for i,v in pairs(list) do
		if v == element then
			return true
		end
	end
end

.....

	if contains( {"EmporerD" }, plr.Name ) then

etc.

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