Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a 1v1 matching system?

I am basically trying to make a 1v1 matching system that teleports the player when they step on a specific platform (should at least contain 2 players) and click a start button(It pops up when two or three players are on both platform) but cant seem to figure out how I should do this. Any Example?

1 answer

✓ Accepted answer

just made this one the fly but i guess it would look something like this:

local player1 = "None"
local player2 = "None"

local Platfrom1 = "" --platoform location in workspace
local Platfrom2 = "" --platoform location in workspace

local Destenation1 = "" --Brick location in workspace
local Destenation2 = "" --Brick location in workspace

local timer = 30 --countdown in 30 seconds

--Get player1
Platfrom1.Touched:Connect(function(hit)
	local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	if player then
		player1 = player.Name
	end
end)

--Get player2
Platfrom2.Touched:Connect(function(hit)
	local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	if player then
		player2 = player.Name
	end
end)

Platfrom2.TouchEnded:Connect(function(hit)
	local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	if player then
		player2 = "None"
	end
end)
Platfrom1.TouchEnded:Connect(function(hit)
	local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
	if player then
		player1 = "None"
	end
end)

while wait(1) do
	timer = timer - 1
	print(timer)
	if timer == 0 then
		if not player1 == "None" then
			if not player2 == "None" then
				if game:GetService("Players"):FindFirstChild(player1)then
					game:GetService("Players"):FindFirstChild(player1):WaitForChild("Character").HumanoidRoot.Cframe = Destenation1.CFrame
				end
				if game:GetService("Players"):FindFirstChild(player2)then
					game:GetService("Players"):FindFirstChild(player2):WaitForChild("Character").HumanoidRoot.Cframe = Destenation2.CFrame
				end	
			end
		end
		timer = 30
	end
end

4 comments

0

there was a problem on line 13 "attempted to index nil with 'Connect' "

0

did u specify the part

0

like u have to replace the "" with game.workspace.platform1

0

I did

This discussion is preserved as it was. New answers, comments, and votes are closed.