I mean, like :
script.Parent.Touched:connect(function(hit) if game.Players:GetPlayerFromCharacter(hit.Parent) ~= nil then while ??? do --Something end end end) script.Parent.TouchEnded:connect(function(hit) if game.Players:GetPlayerFromCharacter(hit.Parent) ~= nil then --Do something that will cancel that upper while loop on line 4 end end)
Get it?
local touchTab = {} script.Parent.Touched:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then touchTab[player] = true while touchTab[player] do --Something end end end) script.Parent.TouchEnded:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then touchTab[player] = nil end end)