print ClonedMap and tell us what it returns
Then whatever instance you’re searching for doesn’t exist within ServerStorage.
Check your instances.
change FindFirstChild to WaitForChild if it yields that means the map doesn’t exist there
I changed it to waitforchild and it just waited infinitely
You said ChosenMap
is an instance? Therefore, you need to pass its .Name
property to :FindFirstChild()
.
local ClonedMap : Instance = game.ServerStorage.Maps:FindFirstChild(ChosenMap.Name):Clone()
Now it says attempt to index nil with clone
When a method tries to compare a value to nil; what you’ve tried to reference doesn’t exist.
This generally isn’t because the instance itself doesn’t exist; instead how you’re referencing the object is wrong.
The issue you’re facing exists within ChosenMap
as a variable. Since you haven’t shared that, I can’t help.
In order to reference the maps in ServerStorage
, ChosenMap
's value should look like:
local ChosenMap : Instance = game:GetService("ServerStorage"):FindFirstChild("Maps"):FindFirstChild("Construction")
local ClonedMap : Instance = game:GetService("ServerStorage"):FindFirstChild("Maps"):FindFirstChild(ChosenMap.Name):Clone()
ClonedMap should be nil
i hate 30 lenght limit
for i, v in pairs(padVotes) do
local number = v
if number > highestNumber then
highestNumber = number
chosen = i
end
end
local ChosenMap = chosen
task.wait(.3)
if ChosenMap == nil or ChosenMap == "0" or ChosenMap == "nil" then
local AvailableMaps = Maps:GetChildren()
ChosenMap = AvailableMaps[math.random(1,#AvailableMaps)]
Status.Value = tostring(ChosenMap).. " has been chosen!"
else
Status.Value = tostring(ChosenMap).. " has been chosen!"
end
task.wait(2)
Status.Value = "Game starting!"
task.wait(2)
print(ChosenMap)
local ClonedMap = game.ServerStorage.Maps:FindFirstChild(ChosenMap):Clone()
print(ClonedMap)
if (ClonedMap ~= nil) then
if ClonedMap == "Radioactive" then
ClonedMap:PivotTo(CFrame.new(490.263, 79.457, -4.343) * CFrame.Angles(0, 0, math.pi))
elseif ClonedMap == "Construction" then
ClonedMap:PivotTo(CFrame.new(490.263, 35.957, -4.343))
end
elseif ClonedMap == nil then
ClonedMap = ChosenMap
ClonedMap = game.ServerStorage:FindFirstChild(ChosenMap)
end
ClonedMap.Parent = workspace
Is the entire part where chosenmap is played. Chosen variable at the beginning is nil.