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

ANTI-Exploit showing a warning in the Output?

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!

2 comments

1

Could you give us the warning it gives? Also you can combine those two scripts.

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.

1 answer

✓ Accepted answer

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)

2 comments

1

How dare you use the deprecated :connect o:

0

@OldPalHappy lol.

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