Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Does not remove the gui from selected players?

Asked by 8 years ago

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

01plr = script.Parent.Parent.Parent
02admins = {"AdvancedCode", "Player1"}
03 
04d = false
05 
06for i = 1, #admins do
07if plr.Name == admins[i] then
08script.Parent:remove()
09 
10if not d then
11d = true
12end
13end
14end

All help is appreciated!

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
8 years ago
Edited 8 years ago

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

Code would look like this;

01local plr = game.Players.LocalPlayer --This is the player!
02local admins = {"AdvancedCode", "Player1"}
03local d = false
04 
05for i = 1, #admins do
06    if plr.Name == admins[i] then
07        script.Parent:Destroy() --'remove' is deprecated. Use Destroy!
08        d = true;
09        break --break the current loop
10    end
11end

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

0
Added a modicum amount of code to this to make it a little bit easier to manipulate, I appreciate this! AdvancedCode 136 — 8y
0
Glad I could help :) Happy developing! Goulstem 8144 — 8y
Ad

Answer this question