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

How do I make my I, v in pairs work properly?

Asked by 4 years ago
Edited by Ziffixture 4 years ago

I'm currently attempting to create a part when you touch it, it spawns in a model from a folder within workspace. I've got most of it down, although my issue is the value of " i, v " not changing after the script runs...

Here is the code...

local used = false

local stage = script.Parent

function OnTouched(part)
    local ObbyTable =  game.Workspace.stages:GetChildren()
    for i, v in pairs(ObbyTable) do
        if used == false then
        local newstage = v:Clone()
        newstage.Parent = workspace.newstages
        newstage.PrimaryPart = newstage.Main
        newstage:SetPrimaryPartCFrame(newstage:GetPrimaryPartCFrame() * CFrame.new(0,0,-34))
        print(i, v)
        used = true 
        end
    end
end

script.Parent.Touched:connect(OnTouched)
0
I don't really know what you're trying to do nor can I really read your script but to put it in simpler terms, i in the amount of the stuffs you have in "ObbyTable" and "v" is the actual stuff inside 0msh 333 — 4y
0
Could you inform us of the contents of ObbyTable? Ziffixture 6913 — 4y
0
What are you trying to achieve? Mr_MidnightMan 0 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

'i' will be 1 because it runs only 1 times. And 'v' will not change because you just clone. Clone doesn't destroy or move.

0
i and v entirely correlate to the contents of the given array. i, or Index matches the current numerical standpoint in correlation to the current iteration, while v, or Value, matches the current element within the array it is iterating past. Ziffixture 6913 — 4y
0
@Feahren What do you want to say? Mr_m12Ck53 105 — 4y
0
I’m merely explaining with technical detail Ziffixture 6913 — 4y
Ad

Answer this question