How to make character collision off when on safe zone

I wanna make fight game that push each others and wanted to make safe zone

1 Like

Do something like this:

local hitboxPart = --the part which is the safe zone

local function savePlayer(hit)
local humRootPart = hit.Parent:FindFirstChild("HumanoidRootPart")
humRootPart.CanTouch = false
humRootPart.CanQuery = false
end

local function unsavePlayer(hit)
local humRootPart = hit.Parent:FindFirstChild("HumanoidRootPart")
humRootPart.CanTouch = true
humRootPart.CanQuery = true
end

hitboxPart.Touched:Connect(savePlayer)
hitboxPart.TouchEnded:Connect(unsavePlayer)

Haven’t tested it so it might not work.

1 Like

CanTouch = true just ignores any Touch / TouchEnded events connected to the part(s), as in those events won’t trigger at all when set to true.
CanQuery = true determines whether the part is considered during spatial query operations, in this case it is not considered.

Look into this:
https://create.roblox.com/docs/building-and-visuals/physics/collision-filtering

Got it! I’ll keep that in mind next time.

1 Like

https://create.roblox.com/docs/reference/engine/classes/BasePart