Im trying to make a math.random/Random.new for choosing a random player
My issue is a client gets a number and other client get other number. I try saving the number on a NumValue and still does not work. Any way to fix this?
local script
local CamYGame = game.ReplicatedStorage.Game.GAME.CamYGame
CamYGame.OnClientEvent:Connect(function()
local Players = game:GetService("Players")
local Camara = workspace.CurrentCamera
local Num = game.ReplicatedStorage.Game.GAME:WaitForChild("Num")
local Character = Players:GetPlayers()[Num.Value].Character
local Humanoid = Character:FindFirstChild("Humanoid")
print(Humanoid, Character, Num.Value)
if Humanoid then
Camara.CameraType = Enum.CameraType.Custom
Camara.CameraSubject = Character
end
end)
Normal Script
local function Round()
local Num = Random.new():NextInteger(1, #Players:GetPlayers())
local Ran = game.ReplicatedStorage.Game.GAME:WaitForChild("Num")
Ran.Value = Num
print(Num)
for _,k in pairs(Players:GetPlayers()) do
Players:GetPlayerFromCharacter(k)
CamYGame:FireClient(k)
end
Player 1: Humanoid, Player1, 1
Player 2: Humanoid, Player2, 1
I dont think is reseting but here is the code
local function Round()
local Num = Random.new():NextInteger(1, #Players:GetPlayers())
local Ran = game.ReplicatedStorage.Game.GAME:WaitForChild("Num")
Ran.Value = Num
print(Num)
for _,k in pairs(Players:GetPlayers()) do
Players:GetPlayerFromCharacter(k)
CamYGame:FireClient(k)
end
for i = RoundLeght, 0, -1 do
wait(1)
print("InGame " .. i)
end
print("Reseting")
RoundEnd()
end