i have this script: THIS SCRIPT IS IN A TEXT LABEL, WICH IS IN A SURFACE GUI, WICH IS IN THE ACTUAL PART
local part = script.Parent.Parent.Parent
local numTouchingParts = 0
local playersTouching = {}
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then --checks to make sure it is a player
local c = hit.Parent
if not playersTouching[c] then --if the player is not already touching the part, add them to the table and increment numTouchingParts by one
table.insert(playersTouching, c)
numTouchingParts = numTouchingParts + 1
end
end
end)
part.TouchedEnded:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local c = hit.Parent
if playersTouching[c] then -- if the player is touching the part then remove them from the table and decrement numTouchingParts by 1
playersTouching[c] = nil
numTouchingParts = numTouchingParts - 1
end
end
end) -- here the player counter script finishes
script.Parent.Text = tostring(numTouchingParts.Value) -- here i tried to make the text label show how many players are on the part
but nothing happens.. can i get some help?
