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

ANTI-Exploit showing a warning in the Output?

Asked by 7 years ago

I am creating a anti-exploit for one of my games currently but I have this issue. I have a feeling it is because I have Filtering Enabled but I am not that sure.

Here is a part of my script that checks for a added forcefield

-- Checks for a added ForceField,

game.Players.LocalPlayer.Character.ChildAdded:connect(function(obj)
    if (obj:IsA("ForceField")) then
        if (obj.Parent == game.Players.LocalPlayer.Character) then
            obj:Destroy()
        end
    end
end)

Also, I am doing a fire script as well!

game.Players.LocalPlayer.Character.ChildAdded:connect(function(obj)
    if (obj:IsA("Fire")) then
        if (obj.Parent == game.Players.LocalPlayer.Character) then
            obj:Destroy()
        end
    end
end)

It would be appreciated for someone to help with this problem! Once I get the answer, I'll confirm it! Also, I would love some tips on how to avoid problems like these if you can give some!

1
Could you give us the warning it gives? Also you can combine those two scripts. antonio6643 426 — 7y
0
I did combine both of them! Here is the output: Something unexpectedly tried to set the parent of ForceField to NULL while trying to set the parent of ForceField. Current parent is Player1. MineKat_Studio 14 — 7y

1 answer

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

ChildAdded is an extremely quick-reacting event. When you tried to destroy the object, it's parent was currently being changed. You have to wait before you can destroy it..

Also, you can combine these two events by using an or statement in your condition.

  • connect is deprecated! Use Connect.
note: remember to use variables to keep your code clean and concise!
local plr = game.Players.LocalPlayer --player
local char = plr.Character or plr.CharacterAdded:Wait() --wait for character

char.ChildAdded:Connect(function(obj)
    if obj:IsA("ForceField") or obj:IsA("Fire") then
        wait(.1) --wait a tiny bit
        obj:Destroy()
    end
end)
1
How dare you use the deprecated :connect o: OldPalHappy 1477 — 7y
0
@OldPalHappy lol. TheeDeathCaster 2368 — 7y
Ad

Answer this question