So, I have a script that shoots a bullet when a tool is selected and the mouse is clicked. The script itself works fine. But right after a player joins and uses it, just like 1 second after he/she joins, the localscript just breaks. Is there a statement that can prevent this from happening?
COMMUNITY QUESTION
LocalScript breaking right after a player joins and uses it?
1 answer
You need to be more specific when asking your questions. If your third comment to your Question had been your Question, we wouldn't have had a problem.
Anyway;
local player = game.Players.LocalPlayer
local character = player.Character
if not character then --If you manually LoadCharacter, this script will sometimes run the first time before a Character exists at all.
player.CharacterAdded:wait()
character = player.Character
end
while not character.Parent do wait() end
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
You need to share the code and the error. There isn't a
fixbugs()line -- because the bug is there because you told Lua that's what you want it to do.Are you sure? Because the script relies on another script and together they add up to 100+ lines. Also, there's no error in the output.
P.S., I didn't want a statement that just fixes the problem. I want a statement that lets the character load before the script does its thing.