#what's the best way to make a safezone

1 messages · Page 1 of 1 (latest)

foggy geyser
#

i made a safezone it work, just wondering what's the best, optimize and efficient

thought player can still exploit by making their client lag and just teleport out before the touchended event manage to delete their forcefield.

function whentouchedOn(hit)
    if not hit.Parent or not hit.Parent:FindFirstChild("Humanoid") then return end
    if hit.Parent:FindFirstChild("ForceField") then return end
    Instance.new("ForceField", hit.Parent)
end
script.Parent.Touched:Connect(whentouchedOn)

function whentouchedOff(hit)
    if not hit.Parent or not hit.Parent:FindFirstChild("Humanoid") then return end
    if hit.Parent:FindFirstChild("ForceField") then
        hit.Parent.ForceField:Destroy()
    end
end

for _,v in pairs(script.Parent.allExit:GetChildren()) do
    v.TouchEnded:Connect(whentouchedOff)
end

while task.wait(3) do
    if script.Parent.CanTouch then
        script.Parent.CanTouch = false
    else
        script.Parent.CanTouch = true
    end
end

the while loop is for making sure the people inside the safezone is getting the forcefield, because you know that roblox hitbox when anchored is buggy, so the hitbox either moving or make the cantouch off and on.

rain night
#

maybe touch start and touch ended? 🤔

#

honesly i didnt read the code so u prob used that 😭

zenith osprey
#

So if the exploiter is outside or inside the other players won't get affected by him

foggy geyser
#

im using takeDamage as a function so if i put forcefield, it automatically disabled the takeDamage function.

the real problem is somehow player manage to get out the safezone with their forcefield.

nova sphinx
#

maybe like use .magnitude to find the distance between 2 object and if .magnitude is below like 67 studs from the safe point it safe

hexed goblet
#

Use raycast with runservice instead touched event