Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

attempt to index a nil value problem?

im having this problem :attempt to index a nil value i want to fix it there is the script:

function onTouch(part)

local human = part.Parent:findFirstChild("Humanoid")

if human ~= nil then

part.Parent:findFirstChild("Head").Transparency = 0.98

part.Parent:findFirstChild("Torso").Transparency = 1

part.Parent:findFirstChild("Left Arm").Transparency = 1

part.Parent:findFirstChild("Right Arm").Transparency = 1

part.Parent:findFirstChild("Left Leg").CanCollide = true

part.Parent:findFirstChild("Left Leg").Transparency = 1

part.Parent:findFirstChild("Right Leg").CanCollide = true

part.Parent:findFirstChild("Right Leg").Transparency = 1

end

end

script.Parent.Touched:connect(onTouch)

--COLORS

--1 = white

--208 = Light stone grey

--194 = Medium stone grey

--199 = Dark stone grey

--26 = Black

--21 = Bright red

--24 = Bright yellow

--226 = Cool yellow

--23 = Bright blue

--107 = Bright bluish green

--102 = Medium blue

--11 = Pastel blue

--45 = Light blue

--135 = Sand blue

--106 = Bright orange

--105 = Br. yellowish orange

--141 = Earth green

--28 = Dark green

--37 = Bright green

--119 = Br. yellowish green

--29 = Medium green

--151 = Sand green

--38 = Dark orange

--192 = Reddish brown

--104 = Bright violet

--9 = Light reddish violet

--101 = Medium red

--5 = Brick Yellow

--153 = Sand red

--217 = Brown

--18 = Nougat

--125 = Light orange

1 answer

✓ Accepted answer

Is your game using R15? If so, some of the body parts don't exist. Go to Game Settings in Roblox Studio (on the topbar). Go to Avatar, then look for Avatar Type, if it is marked as "R15", change it to R6. FindFirstChild returns nil when it fails to find the object.

Also, "findFirstChild" is deprecated. Use "FindFirstChild" instead.

If this answer helped you, make sure to mark it as solved.

1 comment

0

THANK YOU BRO!!!!

This discussion is preserved as it was. New answers, comments, and votes are closed.