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

Stop Motion script? Answered

Asked by 8 years ago

So basically there is a folder in ServerStorage named Investiage, which has models in it.

These models are just one charcter with different arm positions etc They are named like this

F1 F2 F3 F4

and so on,

I want to loop through the children of Investiage get the F1 model put it workspace, destroy it, get the next model which is F2 put it in workspace and so on.

I'm trying to figure out the most efficient way to do this instead of having a 100 line script of trash.

Can anyone help?

for i, v in pairs(game.ServerStorage:GetChildren())
    if v:IsA("Model") then
        if v.Name:sub(1, 1) == "F" then

    end
end

I so far have this, but I want to add them in according to their number

F1 F2 F3 F4

wait() every time one is added into workspace, then destroy and add another and wait() again and destroy and add another then wait() again and so on.

1 answer

Log in to vote
2
Answered by
dyler3 1510 Moderation Voter
8 years ago

You could simply do this by concatenating the number of the loop with 'F' and having the game find the model, then insert it (We'll also need to keep track of the model to delete it). We'll do that like so:

local AmountOfModels=50 --Set this to how many "F's" there are total.
local CurrentModel=nil --Keeps track of the current model

for i=1,AmountOfModels do
    if CurrentModel then
        CurrentModel:Destroy()
    end
    CurrentModel=game.ServerStorage:FindFirstChild("F"..i)
    CurrentModel.Parent=game.Workspace
    wait()
end

This'll work now, but I believe you'll still need to find a way to get it in the correct position. If so, leave a comment below, and I'll help you out with that, but I'll need some more information first.


Anyways, hope this helped :P

-Dyler3

Ad

Answer this question