Having trouble with safezone (solved)

I’m trying to make a Safezone system. I thought using the .touched and .touched ended event would work but if a player jumps in Safezone then their forcefield is removed and added back when the touch the ground again. I don’t want this happening for obvious reasons, 1 being that’s probably horrible for performance, 2 being there’s a split second of time players can damage someone if they’re jumping.

Is there a way I can fix this, or is there a better method to making a Safezone? Any suggestions and/or advice is appreciated!

local Debounce = false
local Players = game:GetService("Players")



script.Parent.Touched:Connect(function(hit)
	local player = Players:GetPlayerFromCharacter(hit.Parent)
	if not hit.Parent:FindFirstChild("Humanoid") then return end
	if hit.Parent:FindFirstChild("ForceField") then return end
	if hit.Parent:FindFirstChild("Humanoid") then
		if Debounce == false then
			Debounce = true
			local forceField = Instance.new("ForceField", hit.Parent)
			print("Player now has forcefield")
			wait(2)
			Debounce = false
		end
	end
end)

script.Parent.TouchEnded:Connect(function(hit)
	local player = Players:GetPlayerFromCharacter(hit.Parent)
	if not hit.Parent:FindFirstChild("Humanoid") then return end
	if hit.Parent:FindFirstChild("ForceField") then
		if Debounce == false then
			Debounce = true
			hit.Parent.ForceField:Destroy()
			print("player left safezone, forcefield destroyed")
			Debounce = false
		end
	end
end)
2 Likes

I don’t see why you cant just expand the safe zone part vertically, but if you cant, a simple thing you could do it wait a few seconds after leaving the safezone to disable the forcefield, that way if the user jumps the forcefield isnt removed.

I did, even while jumping in it the forcefield still goes away then comes back when they touch the ground again even though the safezone is it’s own part and they’re still inside of it while touching

try using regions instead of touch events, there are less edge cases like your describing. Plus, there are many tutorials avaliable

Isn’t region3 deprecated? I thought using deprecated stuff was a big no no

Use Zoneplus

1 Like

Region3 doesnt detect when the player leaves

But for safezone i guess region3 would work

OMG THATS EXACTLY WHAT IM LOOKING FOR!
This’ll take like 5 minutes to set up WWWWWWWWWW

Could I pretty much set it up so when a player enters the zone they"ll get a forcefield then when they leave it’ll be destroyed? Also are you 100% sure this solves the jumping problem?

Yes I am new to Zone plus but you need to like insert the thing it says the link its a bunch of main module scripts so it might seem sketchy but Forever HD is a popular scripter so trust it

I’ll be fine if I insert it into my game right? Like im not gonna get banned, hacked, backdoored, etc?

Nah bro your safe foreverhd is the guy who made adminhd btw

1 Like

i also just found out that this isnt a roblox system the group Nanoblox made it which is owned by foreverHD

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.