Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how to count numbers on a part in a text label?

Asked by 4 years ago

i have this script: THIS SCRIPT IS IN A TEXT LABEL, WICH IS IN A SURFACE GUI, WICH IS IN THE ACTUAL PART

01local part = script.Parent.Parent.Parent
02local numTouchingParts = 0
03local playersTouching = {}
04part.Touched:Connect(function(hit)
05    if hit.Parent:FindFirstChild("Humanoid") then --checks to make sure it is a player
06        local c = hit.Parent
07        if not playersTouching[c] then --if the player is not already touching the part, add them to the table and increment numTouchingParts by one
08            table.insert(playersTouching, c)
09            numTouchingParts = numTouchingParts + 1
10        end
11    end
12end)
13 
14part.TouchedEnded:Connect(function(hit)
15    if hit.Parent:FindFirstChild("Humanoid") then
View all 23 lines...

but nothing happens.. can i get some help?

1 answer

Log in to vote
2
Answered by 4 years ago
01local Players=game:GetService"Players"
02local function getPlayersOnPart(regionPart)
03local pos1 = regionPart.Position+Vector3.new(0,.3,0) - (regionPart.Size / 2)
04local pos2 = regionPart.Position+Vector3.new(0,.3,0) + (regionPart.Size / 2)
05local region = Region3.new(pos1, pos2)
06local partsInRegion = workspace:FindPartsInRegion3(region, nil, 1000)
07local tab,x={},0
08for _, v in ipairs(partsInRegion) do
09        local char = v.Parent
10        local hum = char and char:FindFirstChildOfClass"Humanoid"
11        local player=hum and Players:GetPlayerFromCharacter(char)
12    if player and not tab[player]then
13            tab[player]=true
14            x+=1
15    end
View all 36 lines...
Ad

Answer this question