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

plr.CharacterAdded:wait() not working in StarterPlayerScripts?

If you place this local script in StarterPlayerScripts plr.CharacterAdded:wait() does not work.

local plr = game.Players.LocalPlayer
print("fire check 1")
local char = plr.CharacterAdded:wait()
print("fire check 2")
local torso = plr.Character:WaitForChild("Torso")
print("fire check 3")
plr:GetMouse().Button2Down:connect(function(click)
	if plr.TeamColor == BrickColor.new("Bright blue") then
	print("Derp")
	end
end)

It took me a while to figure out it was StarterPlayerScripts and nothing wrong with the script itself. A work around for this is to use;

repeat wait() until plr.CharacterAdded:connect(function() loaded = true end)

I hope this helps people and I hope roblox fixes this soon!

P.s. Sorry this isn't a question.

1 answer

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()

7 comments

0

good try m8 this doesn't work in starter player scripts!

0

It will run through but it doesn't wait for player to load. This makes your script faulty and not complete the original objective.

0

I don't see how it won't work, I use exactly this and it's never given me any problems.

0

player.Character will automatically be true even if the character hasn't loaded yet. That is why your script doesn't work.

0

No, this works. I'm almost certain.

0

Did you try testing it in depth in the StarterPlayerScripts?

0

Sporkyz, player.Character will be nil if character doesn't exist T_T. I've used this method for years

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