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

DescendantAdded isn't working correctly?

Asked by 4 years ago

so I have this "Anti-Cheat" I'm trying to make but Its literally saying Chat is not on the exceptions even though it is I'm super confused even though it's probably simple :/

player.PlayerGui.DescendantAdded:Connect(function(Descendant)
    if Descendant:IsA("ScreenGui") then
        print(Descendant.Name)
        if Descendant.Name ~= "Chat" or Descendant.Name ~= "BubbleChat" or Descendant.Name ~= "FreeCam"  then
        print(Descendant.Name.." is not on the exceptions ")
        player:Kick("Anti-Cheat:"..player.Name.." Banned for 99999999 days           jk just don't do it again -_-")
        end
    end 
end)
0
Are you trying to kick a player if they chat a certain message? youtubemasterWOW 2741 — 4y
0
no, I'm trying to make it so if a Gui gets added to a players PlayerGui and it's not supposed to be there then they get kicked but I have the Chat gui in the exceptions so it shouldn't kick them but it still does dradon08777 17 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

I figured it out I don't know how this makes much of a difference at all but it works I just have to use a bunch of elseifs here's the code if anyone ever has a similar issue or just wants to steal the code:

print("Anti-Cheat Loaded")
local player = game.Players.LocalPlayer
player.PlayerGui.DescendantAdded:Connect(function(Descendant)
if Descendant:IsA("ScreenGui") then
        local name = Descendant.Name
        print(name)
    if name == "Chat" then
        print(name.." is on the exceptions ")

    elseif name == "BubbleChat" then
        print(name.." is on the exceptions ")
    elseif name == "Freecam" then
        print(name.." is on the exceptions ")   
        else
            print(name.." is not on the exceptions")
            player:Kick("Anti-Cheat:"..player.Name.." Banned for 99999999 days           jk just don't do it again -_-")
        end
    end 
end)

p.s. the point of this script is to make sure an exploiter can't add a Gui in PlayerGui just add a elseif for all of your Guis

Ad

Answer this question