So I have a normal script in startercharacterscripts which gets the parts from the player (r15) so like right hand, right upper arm, left foot, etc. The problem is for some reason I keep on getting "attempt to call a nil value" which I dot understand cus the part of the script that gets the random part works just fine. I used print(partToDestroy) just before the wait and it prints out part7 or part11 or anything like that so I dont under stand why it doesnt work. Any help would be greatly appreciated :)

here's the script btw

while true do

local part1 = script.Parent:FindFirstChild("RightUpperArm")
local part2 = script.Parent:FindFirstChild("RightLowerArm")
local part3 = script.Parent:FindFirstChild("RightHand")

local part4 = script.Parent:FindFirstChild("LeftUpperArm")
local part5 = script.Parent:FindFirstChild("LeftLowerArm")
local part6 = script.Parent:FindFirstChild("LeftHand")

local part7 = script.Parent:FindFirstChild("RightUpperLeg")
local part8 = script.Parent:FindFirstChild("RightLowerLeg")
local part9 = script.Parent:FindFirstChild("RightFoot")

local part10 = script.Parent:FindFirstChild("LeftUpperLeg")
local part11 = script.Parent:FindFirstChild("LeftLowerLeg")
local part12 = script.Parent:FindFirstChild("LeftFoot")

local number = math.random(1, 12)
number = tostring(number)
local partToDestroy = "part"..number

wait(10)

partToDestroy:Destroy()

end

1 comment

0

Even though it's in the character scripts, you may want to try still getting the player.