so, i have a text label that shows how many players are standing on a part. that text label is in a surface gui thats in the actual part. how can i make a 25 seconds timer START when that text label shows 1 player on the part? this is the script for the text label:
local Players=game:GetService"Players"
local function getPlayersOnPart(regionPart)
local pos1 = regionPart.Position+Vector3.new(0,.3,0) - (regionPart.Size / 2)
local pos2 = regionPart.Position+Vector3.new(0,.3,0) + (regionPart.Size / 2)
local region = Region3.new(pos1, pos2)
local partsInRegion = workspace:FindPartsInRegion3(region, nil, 1000)
local tab,x={},0
for _, v in ipairs(partsInRegion) do
local char = v.Parent
local hum = char and char:FindFirstChildOfClass"Humanoid"
local player=hum and Players:GetPlayerFromCharacter(char)
if player and not tab[player]then
tab[player]=true
x+=1
end
end
for _,v in ipairs(Players:GetPlayers())do
tab[v]=not not tab[v]
end
return tab,x
end
local textLabel=script.Parent
local part,debounce=textLabel.Parent.Parent,false
part.Touched:Connect(function()
if debounce then return end;debounce=true
local _,x=getPlayersOnPart(part)
textLabel.Text=tostring(x)
wait(1)
debounce=false;
end)
while wait(4)do
local _,x=getPlayersOnPart(part)
textLabel.Text=tostring(x)
end
