Hey so I’ve been trying to make a game like Mortal Kombat or Street Fighter where it addresses which player is Player 1 and which is Player 2 and puts them on either sides of the screen.
So far I’ve been able to make a script that will clone the player when there is only one in the server, but it breaks when two players join. I’m guessing it is because the script doesn’t know which player to clone, but I just need help assigning a player to Player 1 and Player 2
If your only allowing 2 players in a server you can just create a variable to check wether player one has been taken. Quickly made up this code let me know if there are any bugs. If you want to allow more people you could let the player decide which player they want to be or use a dictionary of some sort. Goodluck!
local IsPlayerOneTaken = false
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
char.Archivable = true;
local clonedChar = char:Clone()
clonedChar.DisplayName = plr.Name
clonedChar.Parent = game:GetService("Workspace");
clonedChar.HumanoidRootPart.CanCollide = false
if not IsPlayerOneTaken then
clonedChar.Name = "Player1"
clonedChar.HumanoidRootPart.CFrame = workspace.PlayerOneStand.CFrame
else
clonedChar.Name = "Player2"
clonedChar.HumanoidRootPart.CFrame = workspace.PlayerTwoStand.CFrame --guessing your second stand is called this
end
end)
end)
What is exactly the error that the output gives? I’m not sure what you mean by
where it doesn’t know which player to clone.
The variable “char” should be assigned when the character gets added to the game so there should be only 1 character to clone, right? The script should indeed be in ServerScriptService, don’t worry about that!
Just make each player have a different Team. When they join put them in a nuetral team, then make a script assigning them to their individual team so it doesn’t crash or wut so ever.
Sorry for late reply. You’re going to need to apply their teams when they join. then have a separate, or if you could combine it within the same script, clone them afterwards.