So what I’m doing is making a gun system where the arms follow your mouse when you shoot your gun. Im changing the C0 property for the “Left Arm” and “Right Arm” motor6d’s in the player’s torso.
This code runs once the script is loaded because I’m trying to get the original position of the arms so the script knows what to revert the arms to when you unequip the gun.
local Char = plr.Character or plr.CharacterAdded:Wait()
local origRightS = plr.Character.Torso:FindFirstChild("Right Shoulder").C0 or plr.Character.Torso:WaitForChild("Right Shoulder").C0
local origLeftS = plr.Character.Torso:FindFirstChild("Left Shoulder").C0 or plr.Character.Torso:WaitForChild("Left Shoulder").C0
The problem is that the script thinks that “Right Shoulder” is Nil, yet it feels like this works randomly as sometimes when you die and respawn, it may or may not work.
why you use FindFirstChild and WaitForChild for the same purpose? just do plr.Character.Torso:WaitForChild("shoulder"), also what is your character rig type?
I use FindFirstChild to make sure i dont break the script if the motor6d isnt loaded yet and i use WaitForChild to make sure i dont yield the script if the motor6d already exists, I use this all the time and It works fine.
did you use R6 because of game settings or it’s your avatar? also, “may or may not work” sounds like your character switched from R6 to R15. also how did you know it’s Nil? error?
Its R6 because of game settings.
It may or may not work because it loads perfectly fine when you first join, but once you die and respawn its like the script cant find your joints.
I know its nil because when i use “findfirstchild or waitforchild()” it gives me “infinite yield”