I've asked tons of people to get up to this point (most of the answers didn't work)

This is my script now:

print("script started")


local part = script.Parent
local Amount = script.Parent.Parent.Space1.SurfaceGui.Amount
local TPService  = game:GetService("TeleportService")
print("locals 1 started")

local PlayerInTable = {}

local PlayersToTeleport = {PlayerInTable}

local player = game.Players.LocalPlayer

Amount.Text = "0/6"

local counter = 0

local debounce = false
print("all locals started")


part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local character = hit.Parent
		local players = game.Players:GetPlayerFromCharacter(character)
		table.insert(PlayerInTable, players)
		print("player is in PlayerTable")
	end

	if PlayerInTable[player] then
		print("player table script running")
		counter = counter + 1
		Amount.Text = counter.. "/6"
		wait(1) --// debounce timeout
		debounce[player] = true
		print(player.Name.. " is in table")
	else
		debounce = false
		print("player not in table")
	end
	 end)

But here is the problem:

if PlayerInTable[player] then
		print("player table script running")
		counter = counter + 1
		Amount.Text = counter.. "/6"
		wait(1) --// debounce timeout
		debounce[player] = true
		print(player.Name.. " is in table")
	else
		debounce = false
		print("player not in table")
	end
	 end)

but goes right to the else and prints "player not in table" why?

(most people I ask just ignore me and they dont know either soo..)

6 comments

0

Is this a LocalScript? And if so, what is the LocalScript's parent?

0

Its not a LocalScript

0

game.Players.LocalPlayer is a read-only property that is locally set to the player instance of the client. However, the property is set only on the client side. This is because on the server, there will never be a client, and therefore the LocalPlayer property will always be set to nil on the server.

0

I mean that does make sense

0

What should I do instead

0

I suggest using a for i, v in pairs() loop to check if player has been inserted into PlayerInTable.