I need help with a script where it matchmakes two-player who have pressed a GUI. They pretty much are queue against each other. Once there two people queue I want the script to do things. Once there matchmaker against a person a mission start. I just need help with the beginning part where the player waits for another player.
You Can make a script Where when they matchmake so make a folder and in that folder put a value which is there username when they click the matchmaking button now make sure its filtering enabled, Then randomize the pairing or make a squad and then start a mission or something like that, then you can just use a script that gives those players the same quest(make sure to put the values that were picked in a different folder which will just make ur life easier) ( I might be confusing)
Yeah, thank you! So, for I did what you said. Once a player clicks the Solo button there name put into a GUI folder. Then I did this after it checks if there more than 2 boolvaludes inside the folder.
while true do
wait(1)
local List = game.ServerStorage.Queue
for i,v in pairs(List:GetChildren()) do
local Players = #game.ServerStorage.Queue:GetChildren()
if Players >= 2 then
print("More than 2 players")
end
end
end
What should I do after this. I want when there players I want them to teleport somewhere. But first I have to get the 2 player boolvalues inside the folder.
now Get the name of those name and then parent it to a new file like this
v.Parent = the folder
if you need any help just tell me
To make this happen you just use the telportation service and you should no how to do it after if you don’t example
for i,v in pairs( game.Players:GetPlayers()) do
if v == name then -- the value name which is player name
--code
end
end
Okay so for I added this to the script.
while true do
wait(1)
local List = game.ServerStorage.Queue
for i,v in pairs(List:GetChildren()) do
local Players = #game.ServerStorage.Queue:GetChildren()
if Players >= 2 then
print("More than 2 players")
local NewQueue = game.ServerStorage.NewQueue
v.Parent = NewQueue
end
end
end
This is what the script does so for https://gyazo.com/fac019a9a79be880fbc2ef4778ca8879
It only puts one player into the folder. i was just wondering if it was possible to get two player in the folder at once.
Yes you can do that, To do that you must wait for two people in the queue and once 2 people just parent them both in there the way you can do this is make a table and add both names in there and then use an in pairs loop and then parent both in the folder
Can I just pay you 150 robux to help me through out this whole thing. I dont want to take up your time and not give you something in return.
Nah its alright, you don’t need to pay because the dev forum is all about improving and learning Plus I’m not busy I’m just bored and decided to help people.
Okay so Im done with the part where I added two people into the folder. What did you say I should do after two players are added into the other folder.
After Added the two people get there username and teleport them to the place using teleportation service
I recommend if this is like only 2 people can stay in there then use or want server lock then use this
Im confused on how to get there usernames or what to do. Do you want me to make another while true do loop for the other folder. Im so confused.
Ok to get the name of the player get the name when the player presses the gui button
--local script under Gui button
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
--code
game.ReplicatedStorage.RemoteEvent:FireServer(player) -- make sure the values are made from the server and then name the values the player names that are going to the server script.
end)
Okay I got the name of the player here the remoteevent script.
local RS = game:GetService("ReplicatedStorage")
local Queue = RS.Events.Queue
Queue.OnServerEvent:Connect(function(Player)
print("Fired")
local Bool = Instance.new("BoolValue", game.ServerStorage.Queue)
Bool.Name = Player.Name
end)
What now?
After being queued with another person you get the player list and check if there name is there and teleport that player to the location by using this script i said before
for i,v in pairs( game.Players:GetPlayers()) do
if v == name then -- the value name which is player username is
--code
end
end
Where should I put the script at inside the remoteevent and use while true do or inside the quenue one. THe quenue one isnt a remotevent it just a while true do loop.
Here both scripts
Bool Value
local RS = game:GetService("ReplicatedStorage")
local Queue = RS.Events.Queue
Queue.OnServerEvent:Connect(function(Player)
print("Fired")
local Bool = Instance.new("BoolValue", game.ServerStorage.Queue)
Bool.Name = Player.Name
local NewPlayers = #game.ServerStorage.NewQueue:GetChildren()
if NewPlayers == 2 then
print("has 2")
end
end)
Quenue Manager
while true do
wait(1)
local List = game.ServerStorage.Queue
for i,v in pairs(List:GetChildren()) do
local Players = #game.ServerStorage.Queue:GetChildren()
local NewPlayers = #game.ServerStorage.NewQueue:GetChildren()
if NewPlayers > 1 then return end
if Players >= 2 then
print("More than 2 players")
local NewQueue = game.ServerStorage.NewQueue
v.Parent = NewQueue
end
end
end
I’m confused about what you mean but if I were to make it I would just put all the script related to the server in serverscriptservice so it allows no exploits to be made and keep organized.