#dictionary
10 messages · Page 1 of 1 (latest)
im trying to make a random map chooser, and it isnt getting the mapName and imageID
--Variables
local RS = game:GetService("ReplicatedStorage")
local map = script.Parent:GetAttribute("Map")
local image = script.Parent:GetAttribute("ImageID")
local mapEvent = RS.Events.MapReload
local maps = {
["TestBaseplate"] = {
mapName = "TestBaseplate",
imageID = 16598957487
},
["Crossroads"] = {
mapName = "Crossroads",
imageID = 0
}
}
print(maps["TestBaseplate"].mapName)
--Functions
local function chosenMap()
local keys = {}
for k, _ in pairs(maps) do
table.insert(keys, k)
end
local chosenMap = keys[math.random(#keys)]
print(chosenMap)
map = chosenMap.mapName --here
image = chosenMap.imageID --and here
script.Parent.MapName.Text = map
end
--Connections
mapEvent.Event:Connect(chosenMap)
- Did you tried printing ?
- Do your event trigger ?
- Is it a local script or a normal script ?
- Maybe you can't set attribute by doing
=and you should read the doc and useSetAttributeinstead
the event triggers, its a normal script, and i set the attribute to something else while still using =
fixed it
So how did you solved
i put the for loop outside of the function i think
dont remember too clearly
i also just used the maps table instead of keys
👍🏽
** You are now Level 3! **