So, I'm back again with another issue. My script is working fine
local activeNPCs = workspace.ActiveNPCs spawns = game.Workspace.Spawns:GetChildren() local function spawnNPC() local NPCs = game:GetService("ReplicatedStorage").AvailableNPCs:GetChildren() local randomNPC = NPCs[math.random(1,#NPCs)] randomNPC.Parent = game:GetService("ReplicatedStorage").UnavailableNPCs local newNPC = randomNPC:clone() newNPC.Parent = activeNPCs newNPC:MoveTo(spawnPos) local newForceField = Instance.new("ForceField",newNPC) game:GetService("Debris"):AddItem(newForceField, 10) end for i = 1, #spawns do chosenspawn = spawns[i] spawnPos = chosenspawn.Position spawnNPC() wait() end
Oddly, though, it's giving me this error. Why is this? There is no problem in the functionality. This is my output.
20:21:50.024 - Auto-Saving... 20:21:52.230 - Position is not a valid member of Script 20:21:52.231 - Script 'ServerScriptService.SpawnNPCs', Line 17 20:21:52.231 - Stack End 20:22:24.397 - Auto-Saving...
Thanks!
Position is not a valid member of Script
You need to ensure that there is not a script inside of that model, otherwise get Children may be attempting to get the position of a script which is infact not possible. As for line 17, it lies under line 2.