here the script:local zone = script.Parent
zone.Touched:Connect(function(hit)
local character = hit.Parent
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
-- This makes the player's health stay at max
humanoid.MaxHealth = math.huge
humanoid.Health = math.huge
-- Optional: Add a visual effect so they know they are safe
if not character:FindFirstChild("SafeForcefield") then
local ff = Instance.new("ForceField")
ff.Name = "SafeForcefield"
ff.Parent = character
end
end
end)
zone.TouchEnded:Connect(function(hit)
local character = hit.Parent
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
-- Reset health to normal when they leave
humanoid.MaxHealth = 100
humanoid.Health = 100
-- Remove the visual effect
if character:FindFirstChild("SafeForcefield") then
character.SafeForcefield:Destroy()
end
end
end)
Download
0 formats
No download links available.
How to create a safe zone in studio lite | NatokHD