Safe Zone Without Orb

Intro

So I’ve been trying to make a safe zone. All of the safe zones I’ve seen plenty of YouTube videos on how to do this. All of this either have an orb or don’t allow gear at all. I was wondering how I could do this but without an orb or not allowing gears.

Code

What do you mean by an orb exactly?

You could give the player a ForceField and check to makesure they dont have a ForceField in the touched connection to not spam them with ForceFields, then in the TouchEnded connection, remove the forcefield.

EDIT:
If you mean orb by the forcefield effect, when you make the forcefield. Set its .Visible to false

1 Like

I believe he means that he doesn’t want a physical part, in which case you’d have to use magnitude, and loop through each player while checking if they’re within bounds of it.

for i,v in next, game.Players:GetPlayers() do
    local char = v.Character
    if char then
        local hrp = char:FindFirstChild("HumanoidRootPart")
        if hrp then
            if (hrp.Position-safezonePos).magnitude < 40 then
                --do stuff
            end
        end
    end
end

Try doing this:

local RunService = game:GetService("RunService")
local Players = game:GetService("Players")

local playersInSafeZone = {}
function doSafeZone(player)
	local Folder
	if not ReplicatedStorage:FindFirstChild(player.Name .. "Tools") then
		Folder = Instance.new("Folder")
		Folder.Name = player.Name .. "Tools"
		Folder.Parent = ReplicatedStorage
	else
		Folder = ReplicatedStorage:FindFirstChild(player.Name .. "Tools")
	end
	local children = player.Backpack:GetChildren()
	 if #children <= 0 then return end -- less then just incase, im paranoid like that
	for _, child in pairs(children) do
		child.Parent = folder
	end
end

local function getTouchingParts(part)
	local connection = part.Touched:Connect(function() end)
	local results = part:GetTouchingParts()
	connection:Disconnect()
	return results
end

local function weakTouchingParts(part)
	local returnTable = setmetatable({}, {mode = "k"})
	local parts = getTouchingParts(part)
	for _, part in pairs(parts) do
		returnTable[part] = true
	end
end

function undoSafeZone(player)
	local Folder
	if not ReplicatedStorage:FindFirstChild(player.Name .. "Tools") then
		Folder = Instance.new("Folder")
		Folder.Name = player.Name .. "Tools"
		Folder.Parent = ReplicatedStorage
	else
		Folder = ReplicatedStorage:FindFirstChild(player.Name .. "Tools")
	end
	local children =  Folder:GetChildren()
	 if #children <= 0 then return end -- less then just incase, im paranoid like that
	for _, child in pairs(children) do
		child.Parent = player.Backpack
	end
end

while true do
	RunService.Stepped:Wait()
	local PlayerList = Players:GetPlayers()
	
	for _, player in pairs(PlayerList) do
		if player.Character then
		local humanoidRootPart = 		 		 		 		 player.Character:FindFirstChild("HumanoidRootPart")
		 		if humanoidRootPart then
					local TouchingParts = weakTouchingParts(humanoidRootPart)
						if TouchingParts[safeZone] then -- i think you can do this, according to the wiki it returns objects which if im not mistaken then works the same as an instance list
							-- define the part of the safe zone
							doSafeZone(player)
							playersInSafeZone[player] = true
						elseif not character:FindFirstChildOfClass("Humanoid").Health <= 0 then
							undoSafeZone(player)
							playersInSafeZone[player] = nil
						else
							playersInSafeZone[player] = nil
						end
					end
				end
		 	end
		end
	end
end
2 Likes

If what you don’t like about the orb (force field) is the visual, you might be able to turn off it’s visual.
ForceField.Visible = false

1 Like

Correction: Orb meaning force field.

1 Like

Didn’t work, am I missing something I tried everyone combination I could think of.

1 Like

I fixed some potential issues. If there are anymore, please tell me.

2 Likes

When you respond, you have this blue orb that’s gives you immunity for some time

2 Likes

It’s simple use this script

hit.Parent:WaitForChild("ForceField").Visible = false