Hey! So I was making a script for my game, so that when the first player joins, they will be assigned a cannon that they can control and a camera. When the second player joins, they SHOULD be assigned to a separate cannon and camera, but for some reason they don’t get assigned to anything. Here’s the code if you need it (sorry if its messy, i was messing around with it a lot)
if firstPlayer == game.Players.LocalPlayer and not workspace.BlueCamera.IsTaken.Value then
--Player 1--
print("Setting up "..player1.Value.Name.."'s client")
workspace.BlueCamera.Taken:FireServer()
camera.CFrame = workspace.BlueCamera.CFrame
--PC--
UIS.InputBegan:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.Q and not processed then
blueCannon.Movement.Move:FireServer("Left", true)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Q then
blueCannon.Movement.Move:FireServer("Left", false)
end
end)
elseif input.KeyCode == Enum.KeyCode.E and not processed then
blueCannon.Movement.Move:FireServer("Right", true)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
blueCannon.Movement.Move:FireServer("Right", false)
end
end)
end
end)
--Mobile--
if UIS.TouchEnabled then
mobileControls.Enabled = true
mobileControls.Left.MouseButton1Down:Connect(function()
blueCannon.Movement.Move:FireServer("Left", true)
mobileControls.Left.MouseLeave:Connect(function()
blueCannon.Movement.Move:FireServer("Left", false)
end)
end)
mobileControls.Right.MouseButton1Down:Connect(function()
blueCannon.Movement.Move:FireServer("Right", true)
mobileControls.Right.MouseLeave:Connect(function()
blueCannon.Movement.Move:FireServer("Right", false)
end)
end)
end
else
--Player 2--
print("Setting up "..player2.Value.Name.."'s client")
workspace.RedCamera.Taken:FireServer()
camera.CFrame = workspace.RedCamera.CFrame
--PC--
UIS.InputBegan:Connect(function(input, processed)
if input.KeyCode == Enum.KeyCode.Q and not processed then
redCannon.Movement.Move:FireServer("Left", true)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Q then
redCannon.Movement.Move:FireServer("Left", false)
end
end)
elseif input.KeyCode == Enum.KeyCode.E and not processed then
redCannon.Movement.Move:FireServer("Right", true)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
redCannon.Movement.Move:FireServer("Right", false)
end
end)
end
end)
--Mobile--
if UIS.TouchEnabled then
mobileControls.Enabled = true
mobileControls.Left.MouseButton1Down:Connect(function()
redCannon.Movement.Move:FireServer("Left", true)
mobileControls.Left.MouseLeave:Connect(function()
redCannon.Movement.Move:FireServer("Left", false)
end)
end)
mobileControls.Right.MouseButton1Down:Connect(function()
redCannon.Movement.Move:FireServer("Right", true)
mobileControls.Right.MouseLeave:Connect(function()
redCannon.Movement.Move:FireServer("Right", false)
end)
end)
end
end