Hello everyone im zamabikillerz101 (Beginner scripter)
I am trying to make a rust based game in roblox (I know its been done) however just for fun, i have gotten 1 node to spawn in random locations, however when i have added 2 other types of nodes into the folder and make the script pick a random node and clone it it doesnt work. can anyone help? keeps returning // 02:14:22.684 - ServerScriptService.Script:10: attempt to index local 'nodes' (a number value) //
My current CODE
--Script for spawning random nodes around the map in random positions :)
--Variables--
local nodeamount = 0 --Set starting amount
local node = game.ReplicatedStorage.Nodes:GetChildren() --Finds the node
local nodes = math.random(1, #node)
while nodeamount < 5 do -- if nodeamount is less than 5 continue the script // if =5 stop script
local nodes = math.random(1, #node)
local cloned = nodes:Clone() --Clone the node
cloned.Name = ("NodeID:" .. math.random(1000))--Assigns a random ID number to the spawned Node
cloned.Position = Vector3.new(math.random(-100,100),1,math.random(-100,100)) --Find a location to spawn the node
cloned.Parent = game.Workspace -- When found location Parent it to the map
cloned.Anchored = true --Stops the node from being moved around
nodeamount = nodeamount + 1 --Increase the int +1 each time until reaches 1
print ("Nodes Currently on the map:" .. nodeamount) -- Prints a message in console
wait(0.5)-- Waits .5 seconds before re reading the script.
end -- End

4 comments
Addition > This will work since you are cloning a random number instead of the object.
Hello Thank you for the answer
However it only spawns 1 type of node instead of the 5 diffrent type of nodes
The code seems correct. Are there definitely 5 different types of nodes in game.ReplicatedStorage.Nodes?