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

How do I remove a ScreenGui for a certain team? [closed]

Asked by 9 years ago

This question already has an answer here:

How can I remove a StarterGUI for a certain team?

This is what some guy helped me with, but it doesnt seem to work! I want to have it like: A guy is on the Bright red team, and as soon as I team him to Bright blue, the GUI needs to be gone!

for i, v in pairs (game.Players:GetPlayers()) do
 if v.TeamColor == "Bright blue" then
-- If the player is in the Bright blue team
for i, obj in pairs (v:WaitForChild("PlayerGui"):GetChildren()) do
 if obj:IsA("ScreenGui") then -- Just in case
obj:Destroy()
end
end
end
end

1
So... where's YOUR attempt at solving the problem or at least debugging it? It's great that you're asking questions, but if you put no effort into it and have people solve every little problem you have, you're just riding off of other people's hard work. Unclear 1776 — 9y
0
I know, yet I tried to fix it myself, but it never really worked out, so I got to this script, and editted it, yet it doesnt seem to work on any possible way. MountySyrus 5 — 9y
0
+ the creator gave it to me personally..So I dont really rip him off..#NoHate MountySyrus 5 — 9y
0
Let's see your tried to fix it myself and we may be able to help ITSolarWinds 25 — 9y
0
This question already has an answer. https://scriptinghelpers.org/questions/17708/- Shawnyg 4330 — 9y

Marked as Duplicate by Shawnyg and Goulstem

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

1 answer

Log in to vote
-1
Answered by 9 years ago

This should work i commented what i changed

for i, v in pairs (game.Players:GetChildren()) do --Get the Children instead
         if v.TeamColor == BrickColor.new(23) then -- BrickColor Codes work better sometimes 23 is Bright blue
            for i, obj in pairs (v:WaitForChild("PlayerGui"):GetChildren()) do
             if obj:IsA("ScreenGui") then
                obj:remove() --remove instead of destroy because logic
            end
        end
    end
end
0
Don't use the same iterator (the 'i', in this example) for different 'for' loops, which is a problem I came across before. It will cause the loop to skip a few things within a table, so please change the iterator (the 'i' for both loops). TheeDeathCaster 2368 — 9y
0
Also noticing, do not use 'remove' to remove a Instance anymore; It has become Deprecated; http://wiki.roblox.com/index.php?title=Remove What Deprecation is; http://wiki.roblox.com/index.php?title=Deprecation TheeDeathCaster 2368 — 9y
Ad