Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Problem with teleporting all players in a party/match?

Asked by 4 days ago

I am having a problem where it only teleports creator of the party instead of everyone in the party.

I am sure the problem is in line 16 inside server script. But I'm not sure what's wrong with it? I have a playerList table to teleport, but it doesn't seem to be working, only the creator of the match/party will get teleported instead of all players in the party.

Code in LOCAL SCRIPT: ~~ ~~

local Players = game.Players
local TeleportService = game:GetService("TeleportService")
local total = script.Parent.Parent.count.mbm
local xd = 1

local typeserver = script.Parent.Parent.ServerTypeName

script.Parent.MouseButton1Click:Connect(function()
    if script.Parent.Parent.ServerCreator.Value == game.Players.LocalPlayer.Name then
        for i, x in pairs (script.Parent.Parent.plrlist:GetChildren()) do -- for multiple members in the party
        if x:IsA('ImageLabel') and xd <= total.Value then
            local member = game.Players:FindFirstChild(x.Name)
                game.ReplicatedStorage.ServerCreation.TeleportationMain:FireServer(member) -- here im sending information to server
            xd = xd + 1
        elseif xd >= total.Value and total.Value > 1 then -- for solo teleport if theres only 1 person in the party
             local member = x
             local creator = script.Parent.Parent.ServerCreator
             game.ReplicatedStorage.ServerCreation.Teleportation:FireServer(member.Name,creator.Value, typeserver.Text)
         else
        local member = x
        local creator = script.Parent.Parent.ServerCreator
        script.Parent.Text = 'Teleporting Solo!'
        game.ReplicatedStorage.ServerCreation.TeleportSolo:FireServer(member.Name, creator.Value,typeserver.Text)
        wait(1)
        script.Parent.Text = 'Teleport'

            end

        end
    end

end)

Code in ServerScript: ~~ ~~

game.ReplicatedStorage.ServerCreation.ListUpdater.OnServerEvent:Connect(function(player,creator, member, num)
    game.ReplicatedStorage.ServerCreation.ListUpdater:FireAllClients(creator, member, num)

end)

local Players = game.Players
local TeleportService = game:GetService("TeleportService")

local list = {}
local id =  5693618263 -- game id that i want the script to teleport to
local id2 = 0
local id3 = 0
game.ReplicatedStorage.ServerCreation.Teleportation.OnServerEvent:Connect(function(player, member, creator, servertype) -- this is where the game teleports you ( im having problem with this line the game wont teleport all player in the list table
    game.ReplicatedStorage.ServerCreation.Teleportation:FireAllClients(member, creator)
wait(2.5)
if servertype == 'Sword Arena' then
            TeleportService:TeleportPartyAsync(id, list)
elseif servertype == 'Lab' then
            TeleportService:TeleportPartyAsync(id2, list)
elseif servertype == 'Tournament' then
                TeleportService:TeleportPartyAsync(id3, list)
    end
end)

game.ReplicatedStorage.ServerCreation.TeleportationMain.OnServerEvent:Connect(function(player, member) -- here the server picked up the argument from client and insert info to list table
    print(list)
    table.insert(list, member)

end)

-- dont worry about this, because this is just function if the party has 1 person
game.ReplicatedStorage.ServerCreation.TeleportSolo.OnServerEvent:Connect(function(player, member, creator, servertype)
game.ReplicatedStorage.ServerCreation.Teleportation:FireAllClients(member, creator)
    wait(5)

print('telelperoersaolo')
if servertype == 'Sword Arena' then
            TeleportService:Teleport(id, player)

elseif servertype == 'Lab' then
            TeleportService:Teleport(id2, player)
elseif servertype == 'Tournament' then
                TeleportService:Teleport(id3, player)
                end
end)

If you can help and tell me what's the problem, that would be greatly appreciated.

0
What is the error say and what line? jakebball2014 84 — 3d
0
It didn't print any errors Feelings_La 21 — 3d
0
When I do table.foreach(list, print), it print all the value ( players ) inside list table which is all players that I want to teleport but it didnt teleport all of the players in the table Feelings_La 21 — 3d

Answer this question