I'm getting this error when I try and change the part properties through the function - line 20. Any help would be appreciated.
function createCharacterAnchors()
torso = character:WaitForChild("Torso")
if torso ~= nil then
print("found")
local function createNewAnchor()
print("started")
local part = Instance.new("Part")
part.Transparency = 1
part.CanCollide = false
part.FormFactor = Enum.FormFactor.Custom
part.Size = 0.2 * Vector3.new(1, 1, 1)
part.TopSurface = Enum.SurfaceType.Smooth
part.BottomSurface = Enum.SurfaceType.Smooth
part.Parent = character
end
end
end
local torsoCore = createCharacterAnchors()
torsoCore.Name = "TorsoCore"
local torsoCoreMotor = createNewMotor()
torsoCoreMotor.Name = "TorsoCore"
torsoCoreMotor.C0 = CFrame.new(0, 0.5, 0) * CFrame.Angles(0, math.pi, 0)
torsoCoreMotor.Part0 = character.Torso
torsoCoreMotor.Part1 = torsoCore

8 comments
Where are you getting character from on line 2? Why is createNewAnchor nested in another function and never called in this snippet?
The character variable is from player.CharacterAdded:Connect(function(character)
Re you using R6 or R15?
I'm using R6, I think the issue stems from line 20 - can I not name the part that the function creates outside of the function?
What is createCharacterAnchors() returning?
My bad I have pasted the non-updated code in, I have made createNewAnchor() a non-local function and torsoCore = createNewAnchor
The createNewAnchor function is working, the code just breaks on line 20.
On line 20 there is nothing to modify because it does not look like your returning the object so It can't modify it