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

Help with welds?

Asked by 10 years ago

I was wondering why isn't this script welding the player's arms to the cloned arms and cloning the left arm? If you manged to fix it please show how and what you did. I got no errors in the output.

01game.Players.PlayerAdded:connect(function(Player)
02        Player.CharacterAdded:connect(function(Character)
03---------------------------------------------------------
04            function MakeDisplayArms()
05---------------------------------------------------------
06                local CurrentCamera = game.Workspace.CurrentCamera
07                local PlayerArms = {
08                    Character["Right Arm"],
09                    Character["Left Arm"]}
10---------------------------------------------------------
11                    for i,v in pairs (PlayerArms) do
12                Character:WaitForChild(v.Name)
13                FoundClonedArms = CurrentCamera:FindFirstChild("Cloned_"..v.Name)--Finds for Cloned parts
14                if not FoundClonedArms then--Litte debounce
15                        print(v)
View all 33 lines...

What is this script suppose to do? This script is suppose to make a fake arm that is hidden in the CurrentCamera and that the player can see his arm when zoomed in.

1 answer

Log in to vote
2
Answered by 10 years ago

I removed the debounce, because it's not needed. Then I moved the 'Return' outside the for loop. In your script, the for loop stopped after cloning the first arm. Then for the extra table, I made that one to hold the new cloned arms. So they can be returned as a table at the end of the function.

01game.Players.PlayerAdded:connect(function(Player)
02        Player.CharacterAdded:connect(function(Character)
03---------------------------------------------------------
04            function MakeDisplayArms()
05    wait()
06---------------------------------------------------------
07                local CurrentCamera = game.Workspace.CurrentCamera
08                local PlayerArms = {
09                    Character["Right Arm"],
10                    Character["Left Arm"]}
11                local ClonedArms = {}
12---------------------------------------------------------
13                for i,v in pairs (PlayerArms) do
14                    Character:WaitForChild(v.Name)
15                    local Clone = v:Clone()
View all 29 lines...

Now for example

1-- If you put:
2print(Arms[2].Name.." and "..Arms[1].Name)
3-- After:
4Arms = MakeDisplayArms()

It will print Left Arm and Right Arm

0
How did you get the arms in the table if you didn't use Table.insert? kevinnight45 550 — 10y
1
The for loop gives an index, which in this case is 'i'. Then at Line 22 of the script above, you can see that I put the 'Clone' in the 'ClonedArms' table at index 'i'. damagex443 325 — 10y
Ad

Answer this question