Find player in part(s)

Hi, I am making a safe zone area so when they spawn and are in lobby, they get infinite steps, else, if they arent, they get 100 steps. Problem is, is that it is really glitchy right now. How would I fix this? Here is my current code:

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 pairs(workspace.SafeZones:GetChildren()) do
	v.Touched:Connect(function(hit)
		if hit.Parent == plr.Character then
			steps.Text = "inf"
		end
	end)
	
	v.TouchEnded:Connect(function(hit)
		if hit.Parent == plr.Character then
			steps.Text = tostring(data[stagetrans.Text])
			return
		end
	end)
end

Plus a video:

You should not be using .Touched and you should be using WorldRoot:GetPartBoundsInBox instead, since it is way more reliable.

1 Like