Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My script is only cloning once and not in the right position?

Asked by 4 years ago

Hi I am trying to clone a model from replicated storage and spawn it in the game at a certain point, but it only spawns the spider once and doesn't spawn it in the right position. Here is my code

local offset = Vector3.new(0,0,5)
while true do
    wait()
    if myHuman.Health <= 250 then
        outerStomach.Transparency = 1
        splat:Play()
        scream:Play()
        boomAnim:Play()
        for i = 1,5 do
            local spider = game.ReplicatedStorage:FindFirstChild("Spider")
            local spiderclone = spider:Clone()
            spiderclone.Parent = workspace
            spiderclone.Cframe = outerStomach.Cframe*offset
            print("Spawned")
        end
        break
    end
end

2 answers

Log in to vote
0
Answered by
Borrahh 265 Moderation Voter
4 years ago

on line 13

 spiderclone.Cframe = outerStomach.CFrame*offset

capital CFrame

0
I did that thank you, but this didn't solve the problem Channy97 10 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
local offset = Vector3.new(0,0,5)
myHuman.Changed:Connect(function()
    if myHuman.Health <= 250 then
        outerStomach.Transparency = 1
        splat:Play()
        scream:Play()
        boomAnim:Play()
        for i = 1,5 do
            local spider = game.ReplicatedStorage:FindFirstChild("Spider")
            local spiderclone = spider:Clone()
            spiderclone.Parent = game.Workspace
            spiderclone.Cframe = outerStomach.Cframe*offset --Not sure if this is a part or a model but if it's a model, make sure to to get the main part of the spider so it can CFrame hope
            print("Spawned")
        end
    end
end)

I changed some things, not sure about the CFrame spider thing though since I don't know if "spiderclone" is a part or a model. Hope this helps

Answer this question