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)
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
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