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

why is Fish Not Teleporting To Part? [No Errors in Output]

Asked by 8 years ago

Heirarchy

Fish>Lighting

FishSpawnScript>Water(a part)>Workspace

Fish Spawn Script What i want is it to spawn a new fish every second. Put what it does it takes the same fish and respawns it.No errors in output btw

model = game.Lighting.Fish
children = model:GetChildren()
cl = model:Clone()

function SpawnFish()

print("Summoning Fishies....")

for i =1, #children do
if children[i] ~= nil then
    local a = cl
local d = script.Parent
print("Teleporting Fish....")
a.Parent = d
wait(.1)
a.CFrame = d.CFrame + Vector3.new(0,1,0)
end
end

print("Fishies Summoned!!!")
end



while true do
    wait(1)
    SpawnFish()


end


1 answer

Log in to vote
0
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

With clones, you have to set the parent. Otherwise, they'll never show up.

model = game.Lighting.Fish
children = model:GetChildren()

function SpawnFish()
    print("Summoning Fishies....")

    for i =1, #children do
        if children[i] ~= nil then
            local a = model:Clone()
            local d = script.Parent
            print("Teleporting Fish....")
            a.CFrame = d.CFrame
            a.Parent = game.Workspace -- Or, wherever you want to put them.
        end
    end

    print("Fishies Summoned!!!")
end



while wait(1) do
    SpawnFish()
end



Ad

Answer this question