Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a 1v1 matching system?

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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
0
there was a problem on line 13 "attempted to index nil with 'Connect' " SinteneI 2 — 3y
0
did u specify the part Pitched_mobile 191 — 3y
0
like u have to replace the "" with game.workspace.platform1 Pitched_mobile 191 — 3y
0
I did SinteneI 2 — 3y
Ad

Answer this question