Disable a script

Hi guys I wanted to make a player count system so when the player count is at 3 a script is being disabled but apparently it is not working I tried using the .disabled = true but it is still not working

here is a link of the video showing the problem

local tp = script.Parent
local playercount = {}
local tpsystem = workspace.tp.Script1
tp.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if not table.insert(playercount, hit.Parent) then
			print(playercount)
			if #playercount < 1 then 
				tpsystem.Disabled = true
			end
			--table.insert(playercount, hit.Parent)
			--print("2")
		end
	end
end)

tp.TouchEnded:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if table.find(playercount, hit.Parent) then
			table.remove(table,-1)
		end
	end
end)

full script there

1 Like

its

script.Enabled = false

to disable a script

3 Likes

Yeah, just like what someone said, it’s script.Enabled not script.Disabled.

Also:

You are putting the wrong arguments through table.remove(), use your table playercount into the first argument of table.remove().

I’d do it like this if I was you;

local index = table.find(playercount, hit.Parent)

if index ~= nil then
    table.remove(playercount, index)
end

3 Likes

aighttt ty <3 so that is why it is not working I’ll notify u when im done rn im not at home

1 Like