Attempt to index nil with waitforchild

This script is in ServerScriptChild. On line 15 it creates a value named InRound

This is a server script in the character. It used to have an error at the beginning, then when the character respawns theres no error. After today’s roblox studio update it says rendering paused for debugging and shows “Exception Hit”. The same thing happened when I put a task.wait(1) in front of it.

Why is this happening the character should be created after the server, and how can it be fixed?

The “plr” variable is nil. That’s the cause in simple term, if you wanna find out why its nil then it’s probably the way you are identifying the player is wrong, double check through printing etc

you could also make it print the variable to see, print(plr)

for you to fix this, i suggest you print the char and ensure its actually a player character, you couldve indexed the wrong path for the player character

the script is directly in StarterCharacterScripts so the parent should be the character

Your script is likely running before the Player’s .Character property is being set to the character model, I suggest using the Player.CharacterAdded or Player.CharacterAppearanceLoaded events (depending on your needs) in one setup script in a container service like ServerScriptService, rather than have it be copied to every character.

I think roblox studio is bugged after the new update. I added print(char.Name) & print(plr.Name) but when testing roblox studio went to the same error, temporarily showed those two lines of code & quickly changed it to before those two lines were added.

I closed roblox studio & opened it again to screen record it & it did it with temporarily showing 1 empty line

In case the script runs while under StarterCharacterScripts, add a check that terminates the script.

-- place this below the plr variable declaration
if not plr then
  return
end

According to that clip, you may have two clones of that script? to double check search “SetOutfit” in the explorer and see how many scripts there is

if you do that and ensure there’s 1 script only and then print plr & char and show results i may be able to help you

1 Like

dude…
People already told you the reason and you can’t dismiss them that simply when they are infact correct.

First of all the way you get player is even by itself not guaranteed by the function if you were to spend at least 1 second reading it.
Try adding like delay for 1 hearbeat of some hacky stuff like:

task.defer(coroutine.running())
coroutine.yield()

In the beggining of a script and it should work

It’s a StarterCharacter script.

Basically his code runs before a character gets assigned to a player.

task.wait(1) was added. I already told you I did it you cant dismiss it simply when I am in fact correct.

There were copies in my character for testing a few weeks ago with that script inside. Thx!

Personally harassing me wasn’t necessary.
You chose to interpret what I said as “toxic,” but all I did was state the truth.
If you’d rather I sugarcoat it, that would mean I’m technically lying - which I’m not going to do.