Problem with spawning model in Replicated Storage

The intended purpose of this script is to spawn the “Shade” Entity in the game through Replicated storage, however when I run the script, nothing happens and the entity is not cloned and inserted into the game.

CODE: > local limit = 10

local replicate = script.Parent
local min = .5
local max = 2
local characterInfo = {
maxhp = 100,
walkspeed = 16
}
local monster = replicate.Shade:Clone()

for i = 1, limit do
local enemy = monster
local humanoid = monster.Humanoid

local scale = math.random() * (max - min) + min
humanoid.BodyHeightScale = scale 
humanoid.BodyWidthScale = scale 
humanoid.BodyDepthScale = scale 
monster.Parent = workspace

for p, v in pairs(characterInfo) do 
    humanoid[p] = v
end 

end

(I’ve tried parenting the newly cloned Model into workspace.)

1 Like

Try cloning the monster by itself to see if it successfully replicates itself to the server.

Make sure this script is a server script, located in workspace or ServerScriptService.
Also make sure that the model is Archivable, or else it won’t clone.

Also-Also, I think you’re trying to spawn multiple enemies.
If so, I’d suggest moving the clone statement into the loop, instead of cloning outside of the loop:

local monster = replicate.Shade

for i = 1, limit do
     local enemy = monster:Clone() -- clone the monster
     local humanoid = enemy.Humanoid
    -- ...
    enemy.Parent = workspace
end
1 Like

It indeed does clone the model, thanks. Now what?

I suggest making sure the humanoid/monster you are trying to put into workspace is a model first if it’s not already.

To put it in workspace:

game.ReplicatedStorage.MODEL NAME.Parent = workspace

To put it back in ReplicatedStorage:

workspace.MODEL NAME.Parent = game.ReplicatedStorage
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.