Script doesnt work

local obbyNames = {"Obby 1", "Obby 2", "Obby 3", "Obby 4", "Obby 5", "Obby 6", "Obby 7", "Obby 8", "Obby 9", "Obby 10", "Obby 11", "Obby 12", "Obby 13", "Obby 14", "Obby 15", "Obby 16"}
local lastObbyPosition = Vector3.new(0, 0, 0)
local offset = Vector3.new(0, 0, 10)
local touchPart = nil
local lastTouchPartSize = Vector3.new(4,1,4.3)

createTouchPart = function(position, size)
	if touchPart then
		touchPart:Destroy()
		wait(0.3)
	end

	touchPart = Instance.new("Part", workspace)
	touchPart.Anchored = true
	touchPart.Position = position
	touchPart.Size = size
	touchPart.CanCollide = false
	touchPart.Transparency = 1

	touchPart.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
			-- Call this function again to reset the touchPart
			local random = math.random(1, #obbyNames)
			local obby = game.ReplicatedStorage[obbyNames[random]]:Clone()
			createTouchPart(lastObbyPosition, lastTouchPartSize)
			obby.Parent = workspace
			if obby then
				obby:SetPrimaryPartCFrame(CFrame.new(lastObbyPosition) * CFrame.new(offset))
				lastObbyPosition = obby.Touch.Position 
				if obby.Touch.Size then
					lastTouchPartSize = obby.Touch.Size
				end
				obby.Touch.Touched:Connect(function()
					local player = game.Players:GetPlayerFromCharacter(hit.Parent)
					if player and not obby.Touch:FindFirstChild(player.Name) then
						local touchValidation = Instance.new("BoolValue")
						touchValidation.Name = player.Name 
						touchValidation.Parent = obby.Touch
						player.leaderstats.Obbies.Value += 1
					end
				end)
			end
			wait(0.5) 
		end
	end)
end

createTouchPart(Vector3.new(-0.687, 0, -9.595), Vector3.new(23.004, 1, 27.007))

This is infinite obby script. If player touches “Touch” part in Obby, new obby gets spawned

if player and not obby.Touch:FindFirstChild(player.Name) then
						local touchValidation = Instance.new("BoolValue")
						touchValidation.Name = player.Name 
						touchValidation.Parent = obby.Touch
						player.leaderstats.Obbies.Value += 1

In here, if player touches “Touch” part, value to “Obbies” gets added. Problem is, if another player already touched that part, other player who also touches that part doesnt get value increased.

I do still need help, it is pretty urgent

The reason why the value to “Obbies” is not being increased for the second player who touches the “Touch” part is because of the following line of code:

if player and not obby.Touch:FindFirstChild(player.Name) then

This line of code checks if the “Touch” part has a child with the name of the player who touched it. If there is already a child with the player’s name, then the code inside the “if” statement will not be executed.
To fix this issue, you can modify the code to check if the player has touched the “Touch” part before by using a table to keep track of players who have touched it.

Wouldnt using table take much space?

Can someone answer me what I asked the message above?

Just use a table, alot of things use it and I notice little perf. Impact from tables

But after I thought about it, every “Touch” part would need a table, and since there would be infinite of them, it wouldnt be possible