Need help with a safezone, not working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Im trying to make a safezone so players in the safezone cannot deal with damage by others with swords.
  2. What is the issue? Include screenshots / videos if possible!
    Issue is i keep getting errors and i cant figure out how to fix them.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Tried looking on fourm, yt. Everything seems to not be what im looking for.

I am using Zone+. I think thats what it called, forgot.

local ServerScriptService = game:GetService'ServerScriptService'
local Http = game:GetService'HttpService'
local Zone = require(game:GetService("ReplicatedStorage").Zone)
local SafeZone = workspace.SafeZone
local NewContainer = Zone.new(SafeZone)




game.Players.PlayerAdded:Connect(function(player)
	
	player.CharacterAdded:Connect(function(character)
		local Humanoid = character:WaitForChild'Humanoid'
		local HumanoidRootPart = character:WaitForChild'HumanoidRootPart'

		local ff = Instance.new('ForceField', character)
		ff.Name = 'Protection'
		ff.Visible = false
		
		local findSafe = player:WaitForChild('isSafe', 5)
		player.isSafe.Value = true
		end)
		
		NewContainer.playerEntered:Connect(function(player) 

			local character = player.Character

			if player ~= nil then
				if player.isSafe.Value == false then
					player.isSafe.Value = true
					local ff = Instance.new('ForceField', character)
					ff.Name = 'Protection'
					ff.Visible = false
				end
			end	
			
		end)
		
		NewContainer.playerExited:Connect(function(player) 

			local character = player.Character
			
			if player ~= nil then
				if player.isSafe.Value == true then
					player.isSafe.Value = false
					if character:FindFirstChild'Protection' then
						character.Protection:Destroy()
						
					end
				end
			end	
			
		end)
	
			
		end)


You are just defining a non-existence value, that is the main issue here. Make sure that the value exists before making any change on it.

1 Like

U need to make a bool value named IsSafe and make it under the localplayer

1 Like

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