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

Help with tables?

Asked by 9 years ago

I was making a CFrame animation thing using tables but the I had trouble adding CFrame values in the table. how would add these CFrame values inside the table?

Output: line 27: '}' expected (to close '{' at line 26) near '='

Player = game.Players.LocalPlayer
Character = Player.Character
Torso = Character.Torso
Mouse = Player:GetMouse()
Tween = require(game.Workspace.Transition)
    if not Character or Character.Parent == nil then
    Character = Player.CharacterAdded:wait()
    end
-----------------------------------------
function MakeWelds()
    local Arms = {Character["Left Arm"],
                  Character["Right Arm"]
    }
    local ArmWelds = {}
    for i,v in pairs (Arms) do
        local Weld = Instance.new("Weld",Torso)
        Weld.Name = v.Name.." Weld"
        Weld.Part0 = Torso
        Weld.Part1 = v
        ArmWelds[i] = Weld
    end
    return ArmWelds
end
Weld = MakeWelds()

Equip = {
Weld[1].C0 = CFrame.new(1.1,0.3,-0.5)*CFrame.Angles(0.5,2.5,1),---LeftArm
Weld[2].C0 = CFrame.new(-1.1,0.3,-0.5)*CFrame.Angles(0.5,-2.5,-1)---RightArm
}
----------------------------------------

Other Questions:

. Would I need separate tables to move left an right arm or will it work for both?If so how?

1 answer

Log in to vote
1
Answered by 9 years ago

You cannot change properties within a table. Try this

Equip = {}
Equip.Weld = MakeWelds() -- Adds the Weld table to the Equip table
-- Instead of  Line 24 to Line 29.

Then you can do something like this

Equip.Weld[1].C0 = CFrame.new(1.1,0.3,-0.5)*CFrame.Angles(0.5,2.5,1)
Equip.Weld[2].C0 = CFrame.new(-1.1,0.3,-0.5)*CFrame.Angles(0.5,-2.5,-1)

And for your second question, you won't need seperate tables for this. If you want to add the CFrame values to a table then you do:

Equip = {}
Equip.Weld = {}
Equip.Weld[1] = CFrame.new(1.1,0.3,-0.5)*CFrame.Angles(0.5,2.5,1)
Equip.Weld[2] = CFrame.new(-1.1,0.3,-0.5)*CFrame.Angles(0.5,-2.5,-1)
0
Thanks,though I wanted to add the cframe values in the table,so later I can iterate it with a loop.Sorry I added this in the last moment. kevinnight45 550 — 9y
1
I changed my answer. damagex443 325 — 9y
Ad

Answer this question