Hi my names are Pixeluted and I want to do Who map win then load but I got error Here is a screenshot with error and script
Thank for read
Hi my names are Pixeluted and I want to do Who map win then load but I got error Here is a screenshot with error and script
Thank for read
Itâs hard to understand whatâs wrong, what would you like us to help you with?
I setting Value where is Name of map then I do load map but I got errorsome bad argument
âNameMapâ is a nil value. Check if itâs there and if itâs a string and then proceed to index.
Something Like:
if NameMap and type(NameMap) == âstringâ then
â Code
end
What Please I do not understand ?
The variable âNameMapâ is nil. Check if itâs not nil and then proceed to index. Thatâs why itâs saying âstringâ expected got nil, because usually you index strings out of dictionaries and especially in this case you want to index a child of âMapsâ which is indexed through its string Name
I now do value is Map but still saying nil Why ?
Check with an if statement to see how it goes.
If I do print then its print nohting its like skiping this is lines of script
game.ReplicatedStorage.Text.Value = "Map "..MapWin.Name.." won."
workspace.VotingPads.Map1.SurfaceGui.Enabled = false
workspace.VotingPads.Map2.SurfaceGui.Enabled = false
workspace.VotingPads.Map3.SurfaceGui.Enabled = false
script.Voting.Value = false
I know why because its skipping lines of script so Value canât be created thats why saing it nil But I donât know why its skipping this is lines of script
Because there is an if statement prior to it, if that statement condition isnât met itâs never set. Which isnât something you want.
Whatâs the âMapâ variable set to? It looks like itâs probably skipping over the entire if statement because Map isnât âMap3â
Its voting I got only one map so I voting for map3 so if map3 win I want load it
But what is it set to? Are you sure âMapâ is actually set to the right value?
Everyone I fixed it Its be because I do wrong voting
Why donât you name your map names, randomize the index (as selection) and clone from there?
Looks something like this:
-- Server Script
local replicatedStorage = game:GetService("ReplicatedStorage")
local mapsFolder = replicatedStorage:WaitForChild("Maps")
local assetsFolder = workspace:WaitForChild("Assets") -- where map is stored once cloned
function changeMap()
-- Remove old map if valid
if #assetsFolder:GetChildren() > 0 then
for _,v in pairs(assetsFolder:GetChildren()) do
v:remove()
end
end
local rand = math.random(1,#mapsFolder:GetChildren())
for i,v in pairs(mapsFolder:GetChildren()) do
if i == rand then
v:Clone().Parent = assetsFolder
end
end
end
Use case:
-- Changes the map every second twenty times.
local x = 0
repeat wait(1) print("New map") changeMap() x = x + 1 until x == 20
Sir what I do not understand your script Can you explain