I have a script below that is supposed to be a "Safe Area", but I'm having multiple issues. First of all, when spawning, players are supposed to get a ForceField but it is very inconsistent. Sometimes I will have one and sometimes I won't. The second issue is players losing their ForceField even when they're still inside the Safe Area. I have tried multiple things, but the current setup is 4 different spawn pads on the top floor of the arena and the Safe Area is a part that covers every single stud of the top floor.
local safearea = script.Parent
safearea.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("HumanoidRootPart") and not hit.Parent:FindFirstChild("ForceField") then
local forcefield = Instance.new("ForceField")
forcefield.Parent = hit.Parent
hit.Parent:FindFirstChild("Humanoid").JumpPower = 0
end
end)
safearea.TouchEnded:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("HumanoidRootPart") and hit.Parent:FindFirstChild("ForceField") then
hit.Parent:FindFirstChild("ForceField"):Destroy()
hit.Parent:FindFirstChild("Humanoid").JumpPower = 50
end
end)

5 comments
If you'd like i can send an answer with my safezone script and you can alter it.
I'd rather you help me fix it but that's fine I guess
Does it work if you walk into the area but not spawn into the area?
Yes, but like I said the ForceField will randomly go away even when you're inside it.
I didn't really wanna do a ForceField, some games just have safe areas where players inside it don't take damage, Ninja Legends is one example. I just don't know how they do it.