local firstChosenPlatform = GuessPlatforms:GetChildren()[RandomNumber1]
local secondChosenPlatform = GuessPlatforms:GetChildren()[RandomNumber2]
if firstChosenPlatform and secondChosenPlatform then
firstChosenPlatform.CanCollide = false
secondChosenPlatform.CanCollide = false
Event:FireClient(firstChosenPlatform, secondChosenPlatform)
end
local GuessPlatforms = script.Parent.Parent:WaitForChild("GuessPlatforms")
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local randomPlatforms = {}
local function pickRandomPlatforms()
local RandomNumber1 = math.random(1, #GuessPlatforms:GetChildren())
local RandomNumber2 = math.random(1, #GuessPlatforms:GetChildren())
while RandomNumber1 == RandomNumber2 do
if RandomNumber1 ~= RandomNumber2 then
print("Fixed")
else
RandomNumber1 = math.random(1, #GuessPlatforms:GetChildren())
end
wait()
end
return RandomNumber1, RandomNumber2
end
local RandomNumber1, RandomNumber2 = pickRandomPlatforms()
local firstChosenPlatform = GuessPlatforms:GetChildren()[RandomNumber1]
local secondChosenPlatform = GuessPlatforms:GetChildren()[RandomNumber2]
if firstChosenPlatform and secondChosenPlatform then
firstChosenPlatform.CanCollide = false
secondChosenPlatform.CanCollide = false
Event:FireClient(firstChosenPlatform, secondChosenPlatform)
end
If you paste this script and run a playtest, it’s gonna run the script as soon as you spawn in.
To get the players, you might want to use PlayerAdded.
local GuessPlatforms = script.Parent.Parent:WaitForChild("GuessPlatforms")
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local randomPlatforms = {}
local function pickRandomPlatforms()
local RandomNumber1 = math.random(1, #GuessPlatforms:GetChildren())
local RandomNumber2 = math.random(1, #GuessPlatforms:GetChildren())
while RandomNumber1 == RandomNumber2 do
if RandomNumber1 ~= RandomNumber2 then
print("Fixed")
else
RandomNumber1 = math.random(1, #GuessPlatforms:GetChildren())
end
wait()
end
return RandomNumber1, RandomNumber2
end
local RandomNumber1, RandomNumber2 = pickRandomPlatforms()
local firstChosenPlatform = GuessPlatforms:GetChildren()[RandomNumber1]
local secondChosenPlatform = GuessPlatforms:GetChildren()[RandomNumber2]
game.Players.PlayerAdded:Connect(function(player)
if firstChosenPlatform and secondChosenPlatform then
firstChosenPlatform.CanCollide = false
secondChosenPlatform.CanCollide = false
Event:FireClient(player, firstChosenPlatform, secondChosenPlatform)
end
end)
Re-try again if it didn’t work, I forgot to add the player argument to the FireClient.