I need to use a value from array as name of the map in the path to it
The Game says that that array[1] is not there
function Voting.PrepareGui(array)
local Remote = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("VotingPrepareGui")
Remote:FireAllClients(array[1], game.ServerStorage.Maps.array[1].Image)
Remote:FireAllClients(array[1], game.ServerStorage.Maps.array[2].Image)
Remote:FireAllClients(array[1], game.ServerStorage.Maps.array[3].Image)
end
So the array is always 3 words that are same to maps names in explorer. I need make the game read it not like “Maps.array[1].Image” but “Maps.City.Image”.
function Voting.PrepareGui(array)
if typeof(array) == 'table' and array ~= nil then
local Remote = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("VotingPrepareGui")
Remote:FireAllClients(array[1], game.ServerStorage.Maps.array[1].Image)
Remote:FireAllClients(array[1], game.ServerStorage.Maps.array[2].Image)
Remote:FireAllClients(array[1], game.ServerStorage.Maps.array[3].Image)
else
warn('Array ~= nil or not table')
end
end
If it does not know let me know whats in the output.
No, The problem is another. It is always an array but it wont read part of it as what it contains.
Like, I give him box and he sees box, but I need game to open that box. I need to get the value (name of map) hiding in that part of array.
if GameM.GetPlayers() > 1 then
local array = Voting.MapsGet(3)
Voting.PrepareGui(array)
Voting.Start()
wait(15)
Voting.End()
GameM.RolesGive(PlayersAmount)
local Map = Maps[math.random(1, #Maps)]
GameM.LoadMap(Map)
GameM.LoadPlayers()
Intermission:Stop()
Playing:Play()
GameM.GameRound()
GameM.Clear("DamageZone")
GameM.BackToLobby()
GameM.MapUnLoad()
else
Remote:FireAllClients("Need More Players")
wait(3)
end
This is part code where I call function, All is requed and it works
local Voting = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("VotingPrepareGui")
Voting.OnClientEvent:Connect(function(MapName, Image)
script.Parent.MapText1.Text = MapName
script.Parent.Image = Image
end)
type or paste code here
And this is one of the codes that receives, But it cant get image because path is not complete, array[1] is not in maps because it is read as “array[1]” not “City”
function Voting.PrepareGui(array)
local array1 = array[1]
local array2 = array[2]
local array3 = array[3]
local Remote = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("VotingPrepareGui")
Remote:FireAllClients(array1, game.ServerStorage.Maps.array1.Image)
Remote:FireAllClients(array2, game.ServerStorage.Maps.array2.Image)
Remote:FireAllClients(array3, game.ServerStorage.Maps.array3.Image)
end
Also if this doesn’t work can you show me what are the values in array?