Why does it say this is it because of line 13 and it's loop?If so why and how do I fix it? Output:
22:51:16.693 - Unable to cast Instance to bool
22:51:16.694 - Script 'Workspace.Script', Line 12 - global MakeDisplayArms
22:51:16.694 - Script 'Workspace.Script', Line 28
22:51:16.695 - Stack End
22:51:16.695 - Disconnected event because of exception
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)--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.
The problem is EXACTLY what it says it is. The second argument to findFirstChild() is a BOOL value, v is an INSTANCE.
The CORRECT way to add strings together is by using ".."
Example
local MyString = "Hello " local player = "Player" local JoinedString = MyString .. player print(JoinedString) --> Hello Player
Your code would be
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 -- IS V A OBJECT OR A STRING? IF IT IS AN OBJECT, I WOULD USE v.Name FoundClonedArms = CurrentCamera:FindFirstChild("Cloned_" .. v)--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)
Disclaimer: untested code, report future problems.
I see you're trying to concatenate a string, try this.
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.Name --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)
More information: http://wiki.roblox.com/index.php?title=Concatenation