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

Owner gui script showing for everyone instead of certain player. How do i fix it?

This script is placed inside a screengui, so is the textbutton. The problem with this script is that it's not working at all (also, there are no errors in the output), everyone can see the text button (even though the property of being visible is disabled).

if game.Players.LocalPlayer.Name == "Player1" or "YoBoi1337" then
script.Parent.TextButton.Visible = true
else
script.Parent.TextButton.Visible = false
end

1 answer

✓ Accepted answer
local AuthorizedPlayers = {291900436}

local Player = game:GetService("Players").LocalPlayer

function checkPlayer()
	for i,v in pairs(AuthorizedPlayers) do
		if Player.UserId == v then
			return true
		end
	end

	return false
end

local isAuthorized = checkPlayer()

if isAuthorized == true then
	script.Parent.Enabled = true
else
	--The ScreenGui's enabled property stays as false.
end

We have a table called AuthorizedPlayers that contains a bunch of userIds. We have a variable for the localplayer. We run checkplayer, which is a function that loops through the table AuthorizedPlayers to see if the userId is in the table. If that is the case we return true. If not, we return false. We run the function using the variable and if it returns as true we enable the screengui, if not, we do nothing since the screen gui should have the enabled property false beforehand.

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