Sorry about reposting, I have a new issue with it, an output error. Again, simple script just I see an output error. The error is:
12:42:13.104 - Position is not a valid member of Model
So whats this mean? Here is the code:
local z = game.ReplicatedStorage.Zombie local zc = z:Clone() local fm = game.Workspace:FindFirstChild("Map") local fs = fm:GetChildren("ZSpawn") while true do wait(10) if fm then for i = 1,30 do zc.Parent = game.Workspace zc.Position = fs.Position print("Spawned") end end end
I assume it has something to do with it trying to change the position of the model I cloned into the Workspace. I just don't know how to fix this? Trying to spawn them all at that position, not spawn one then change it's position. Any help is greatly appreciated :)
You actually can't change the position of a model like that because models do not have a position property. The two ways to do this would be:
Use MoveTo.
MoveTo is basically what you're doing. It changes the position of every part in the model to the chosen Vector3. This is most likely the best choice.
local z = game.ReplicatedStorage.Zombie local zc = z:Clone() local fm = game.Workspace:FindFirstChild("Map") local fs = fm:GetChildren("ZSpawn") while true do wait(10) if fm then for i = 1,30 do zc.Parent = game.Workspace zc:MoveTo(fs.Position) print("Spawned") end end end
Use CFrame.
CFraming a part in the model will set that part's position to a certain spot (and other parts in the model spawn relative). The reason this isn't the best is because the zombie may glitch out when spawning.
local z = game.ReplicatedStorage.Zombie local zc = z:Clone() local fm = game.Workspace:FindFirstChild("Map") local fs = fm:GetChildren("ZSpawn") while true do wait(10) if fm then for i = 1,30 do zc.Parent = game.Workspace zc.CFrame = CFrame.new(fs.Position) print("Spawned") end end end
You can't set a part's position because that would break it's joint.
Hope this helped! If so, accept/upvote! If not, burn your computer down.
~Chem