How to make a safe zone

Ik I could use the touched and touchended event but when i used it and jumped inside the safe zone it would make me leave the safe zone

1 Like

u could use this module, very helpfull Hitbox Service, easily create Accurate Hitboxes using minimal scripting!, as this error has been already posted, Touched Event Fires Without Touching? - #3 by kinglol123468

1 Like

So ur saying using region3 is better than touch events?

1 Like

Yep it is. I’ve used that module before and itks realllllyyyyyy good. I love it! 100% recommended

2 Likes

No, region3 is deprecated

This text will be blurred

I believe region3 is not deprecated. But a lot of plugins are usually better than region3

EDIT: Not deprecated see API: Region3

Deprecation doesn’t immediately take away functionality, but it basically discontinues support (or at least encouragement) of using the feature.

Functions related to region3 are, either way the semi-recently added spatial query API should be favored over region3: Introducing OverlapParams - New Spatial Query API

edit: make sure to include your code when posting here @Philipceo90

Region 3 is NOT deprecated. The old ways of reading a region 3 ARE deprecated

Thanks for the clarification, gonna take a look at this new API and replace my regions3 most likely.

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

local safeZone = workspace.Part --Example.

local function onStepped()
	local playersInZone = {}
	local partsInPart = workspace:GetPartsInPart(safeZone)
	for _, part in ipairs(partsInPart) do
		local model = part:FindFirstAncestorOfClass("Model")
		if model then
			local player = players:GetPlayerFromCharacter(model)
			if player then
				table.insert(playersInZone, player)
			end
		end
	end
	for _, player in ipairs(players:GetPlayers()) do
		local character = player.Character
		if character then
			local forceField = character:FindFirstChildOfClass("ForceField")
			if table.find(playersInZone, player) then
				if forceField then return end
				forceField = Instance.new("ForceField")
				forceField.Parent = character
			else
				if forceField then
					forceField:Destroy()
				end
			end
		end
	end
end

run.Stepped:Connect(onStepped)

You can use the instance method GetPartsInPart() to get the parts inside a part. In addition to this you can parent a “ForceField” instance to the player’s character model in order to make them invulnerable to damage.

https://gyazo.com/7fab0e2ef728b38d80078ca82c3c9576