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

How would I concatenate this?

Asked by 10 years ago

I need to concatenate the parts name to "Clone_" but I can't because I keep getting a error in the output.How would I concatenate this?If you manged to fix please show how and what you did.

Output:

Workspace.Script:16: attempt to concatenate local 'v' (a userdata value)

game.Players.PlayerAdded:connect(function(Player)
        Player.CharacterAdded:connect(function(Character)
---------------------------------------------------------
            function MakeDisplayArms()
---------------------------------------------------------
                local CurrentCamera = game.Workspace.CurrentCamera
                local PlayerArms = {
                    Character["Right Arm"],
                    Character["Left Arm"]}
---------------------------------------------------------
                    for i,v in pairs (PlayerArms) do
FoundClonedArms = CurrentCamera:FindFirstChild("Cloned_"..v.Name)--Finds for Cloned parts
                if not FoundClonedArms then--Litte debounce
                        local ClonedArms = v:Clone()
                        ClonedArms.Parent = CurrentCamera--Hides it from everyone else
                        ClonedArms.Name = "Cloned_"..v --Renames it
                        ClonedArms.CanCollide = false
                        local Weld = Instance.new("Weld")
                            Weld.Part0 = v--Welds it Arms
                            Weld.Part1 = ClonedArms
                        return ClonedArms
                        else
                    return FoundClonedArms
                    end
                end
            end
---------------------------------------------------------           
            MakeDisplayArms()
        end)
end)


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.

0
Look at line 16. BlueTaslem 18071 — 10y
0
Oh my bad kevinnight45 550 — 10y

1 answer

Log in to vote
4
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

v, as the error says is a userdata object (that just means its a ROBLOX object of some kind - an Instance, a CFrame, a BrickColor).

You can't actually concatenate those, since they aren't strings. Since they are ROBLOX instances, you are probably intending to use the objects Name, so just explicitly use that:

"Clone_" .. v.Name

This works since the Name property is a string.

0
I changed it to the name property and I still got the same error. kevinnight45 550 — 10y
0
Look at line 16. BlueTaslem 18071 — 10y
Ad

Answer this question