#Trying to check if ANY item from an array exists.
1 messages · Page 1 of 1 (latest)
Also for if it helps. Currently im just trying out LUAU in general so im trying to script random stuff.
Heres the current script that im using for this randomizer. Everything works but the checking array since i cant use "firstchild" on it
tried to send the current script and this happened
`while true do
if workspace:FindFirstChild(partArray) then
print("Already Spawned!!")
else
local RNG = math.random(0,1000)
if RNG >= 0 and RNG <= 10 then -- 0.1
local respawnPart6 = partClone6:Clone()
respawnPart6:PivotTo(CFrame.new(spawnPos, lookAtPos))
respawnPart6.Parent = workspace
elseif RNG >=11 and RNG <=60 then -- 5
local respawnPart5 = partClone5:Clone()
respawnPart5:PivotTo(CFrame.new(spawnPos, lookAtPos))
respawnPart5.Parent = workspace
elseif RNG >=61 and RNG <=160 then -- 10
local respawnPart4 = partClone4:Clone()
respawnPart4:PivotTo(CFrame.new(spawnPos, lookAtPos))
respawnPart4.Parent = workspace
elseif RNG >=161 and RNG <=310 then -- 15
local respawnPart3 = partClone3:Clone()
respawnPart3:PivotTo(CFrame.new(spawnPos, lookAtPos))
respawnPart3.Parent = workspace
elseif RNG >=311 and RNG <=560 then -- 25
local respawnPart2 = partClone2:Clone()
respawnPart2:PivotTo(CFrame.new(spawnPos, lookAtPos))
respawnPart2.Parent = workspace
elseif RNG >=561 and RNG <= 1000 then -- 45
local respawnPart1 = partClone1:Clone()
respawnPart1:PivotTo(CFrame.new(spawnPos, lookAtPos))
respawnPart1.Parent = workspace
end
print(RNG)
end
wait (5)
end`
Can’t do it with an array
Also I don’t know what you’re trying to do still
ofc lemme explain
So I can’t tell you what the proper way to do it is
so like im tryna make a lil randomizer that spawns a colored brick depending on the number given by the variable RNG on the 5th line.
Thing is i want it to spawn 1, and not spawn any more until that one is gone
Let me send you the whole thing
i might have to send it in a file since it doesnt fit here ^^"
@wild nimbus tell me if you need more info and ill gladly oblige
So you only want it to spawn something from the array if it sees that nothing from the array is already spawned?
indeed
oh and if youre curious
this what happens if i leave it for a few seconds
What’s in the array?
the 6 brick colors/rarities
Basically the local partClone1 = workspace.Testing.Testparts["Rarity 1"] partClone1.Name = "Rar1" partClone1.Parent = replaceItems
im trying to explain myself hol on
basically it just sets up the bricks to be cloned under a new name and indexed in a folder that contains them
the array contains the cloned versions of the brick
Use the array to hold the parts to be cloned, then when cloning a part parent it under a folder made specifically for the cloned parts. Then all you have to do is check if folder:GetChildren() returns a list with anything in it
hol on im trying to figure out how to do it
** You are now Level 2! **
No, it’ll always return an array. If it has no children the array will be empty
If it has no children*
and if it has anything, i can just do if #array >= 1 then ....
?
i bricked studio again xd
You may want to look into weighted rng
So you never have to do this else if crap again
Thanks! Ill look at it right now :D
also
now that im on pc
local partArray = {nil, nil, nil,, nil, nil, nil}
and then youre checking for workspace:FindFirstChild(partArray)
(findfirstchild takes a string)
Yeah what i did for that is just make an array that gets updated with the children in a folder, then it checks if the folder is empty, if it is, it spawns a new piece :D
oh
Im slowly understanding how types of data work in LUAU
Yeah its here not in the code upthere, mb
If you are curious about the whole script i can send it to you btw :D
** You are now Level 3! **