I am making a randomly generated obstacle course (often called an “obby”) and I am making three different levels, “L” for low, “M” for medium and “H” for high. The script can pick ladders that will increase the height, thats the problem.
If the script goes up to the highest height (“H”) I want it to not be able to pick ladders anymore, however the script seems to think differently.
here is the script:
local num = #script.Parent.levels:GetChildren()
local levels = script.Parent.levels
local items = game.ServerStorage.obby.hard:GetChildren()
local HML = "N"
local LMR = "M"
for i,v in pairs(levels:GetDescendants()) do
if v:IsA("Part") then
v.Transparency = 1
v.CanCollide = false
end
end
for i = 1,num,1 do
randomitem = items[math.random(#items)] --items[math.random(1, #items)]:Clone()
if HML == "H" and randomitem.way.Value ~= "up" then
print(":( ".. i)
repeat
randomitem = items[math.random(#items)]
wait()
until randomitem.way.Value == "neu"
end
local randomitemclone = randomitem:Clone()
randomitemclone.Parent = workspace
randomitemclone:SetPrimaryPartCFrame(levels[i][HML][LMR].CFrame)
if randomitem.way.Value == "up" and HML ~= "H" then
if HML == "L" then
HML = "M"
elseif HML == "N" then
HML = "H"
end
end
print(i, HML)
end
This is the problem child:
repeat
randomitem = items[math.random(#items)]
wait()
until randomitem.way.Value == "neu"
It runs, the print right above it prints fine. But for some reason the script right above seems to think differently. Any help would be appreciated