My game has an anti-spawn killing system, where players are given a 10 minute forcefield as long as they do the following:
-
As long as they within the invisible spawn protection walls that surrounds the building(s) where the player spawns, as seen below:
-
They do not pull out any sort of tool/weapon from their inventory
-
There is a fallback protocol in case the above fail - if someone somehow, someway, kills someone while they have a forcefield on, the kill handler will delete that forcefield.
Below is the code for this:
--- below line is inside the code that handles kills
local ff = killer.Character:FindFirstChildOfClass("ForceField"); if ff then ff:Destroy(); end;
---below lines/functions are inside a character added function
local DeleteFF; DeleteFF = Head.Touched:Connect(function(hit)
if not hit or not hit.Parent then return; end;
local ff = char:FindFirstChildOfClass("ForceField"); if not ff then return; end;
if hit.Parent.Name ~= "antiSKSystem" then return; end;
ff:Destroy();
DeleteFF:Disconnect();
end);
local DeleteFF_Tool; DeleteFF_Tool = char.ChildAdded:Connect(function(tool)
if not tool:IsA("Tool")then return; end;
local ff = char:FindFirstChildOfClass("ForceField"); if not ff then return; end;
ff:Destroy();
DeleteFF_Tool:Disconnect();
end);
Now, the above system seems pretty watertight, but there is a big glitch that occurs. It is pretty common that within 30-60 seconds of spawning, even if you do not leave your base bounds or don’t pull out a weapon, the forcefield will just, disappear. It doesn’t make any sense, since the “Duration” property of all the spawns is set to be 600 (10 minutes).
This is a big issue since this will commonly happen to people who just started playing the game, i.e. don’t have much protection from their base from more established players, and oftentimes results in intense spawn killing/camping that leads to lower playtimes and lowered retention scores.
I desperately need help with this.