Find player in area

Don’t rely on .Touched as it is inaccurate (for your use-case), instead you should use a module like ZonePlus.

local ZN = --insert zone module 

local SafeZones = workspace.SafeZones
local plr = game.Players.LocalPlayer
local steps = plr.PlayerGui:WaitForChild("StepsGUI").Frame.TextLabel
local stagetrans = plr.PlayerGui:WaitForChild("StageTransfer").CurrentStage
local mod = plr.PlayerGui:WaitForChild('StoreSteps')
local data = require(mod)

for _,v in ipairs(workspace.SafeZones:GetChildren()) do
	local zone = ZN.new(v)
	
	zone.playerEntered:Connect(function(player)
		if player == plr then
			steps.Text = "inf"
		end
	end)

	zone.playerExited:Connect(function(player)
		if player == plr then
			steps.Text = tostring(data[stagetrans.Text])
			return
		end
	end)
end
1 Like