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

Does not remove the gui from selected players?

I want to remove this ScreenGUI from selected Players but it does not work. The code is below.

plr = script.Parent.Parent.Parent
admins = {"AdvancedCode", "Player1"}

d = false

for i = 1, #admins do
if plr.Name == admins[i] then
script.Parent:remove()

if not d then
d = true
end
end
end

All help is appreciated!

1 answer

✓ Accepted answer

You should use a LocalScript - so you can index game.Players.LocalPlayer to retrieve the client easily.

Code would look like this;

local plr = game.Players.LocalPlayer --This is the player!
local admins = {"AdvancedCode", "Player1"}
local d = false

for i = 1, #admins do
	if plr.Name == admins[i] then
		script.Parent:Destroy() --'remove' is deprecated. Use Destroy!
		d = true;
		break --break the current loop
	end
end

Assuming the script's Parent is the gui, this should work.

2 comments

0

Added a modicum amount of code to this to make it a little bit easier to manipulate, I appreciate this!

0

Glad I could help :) Happy developing!

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