Output giving errors although code is still running?

Hi,

I’m trying to figure out why the output is giving errors despite the game running fine?

An example is that the output states that a particular part of my tool doesn’t exist yet the tool works perfectly fine in-game.

These errors only accumulate into my output box AFTER I reset.

Please include the code you are using so we can be better equipped to help you with your problem, and include any errors/warnings.

It’s not the code, it’s just an issue that errors continue to accumulate into my output box despite that fact that the game is running perfectly fine. The output claims that there is an error although the tool is running as intended.

Another example as you can is that the code for the chat system I made is yielding, but when I use the chat, it works as intended and doesn’t show any signs of problems.

It’s clearly an issue with your code, the output does not lie, can you still post it anyways. With tools, sometimes the children don’t exist right away when you respawn, so you might want to wait for the objects to exist.

How could it be an issue albeit the systems working perfectly fine and showing no signs of problems?

It’s likely that the error is due to some code that is inside an event. Errors that happen inside event connections do not stop code. They just stop code that happens nested inside the event connection after the error.

1 Like

How could it be that it only happens after I reset?

Here is an example:

Weapon:WaitForChild("Blade")

I stated that line in the beginning of the code just for testing, and even after that, it errors somewhere down the road.

Another example is:
local NewText = MessageBox:WaitForChild("Template"):Clone()

How can “Template” suddenly disappear after I reset? The GUI doesn’t even have “ResetOnSpawn” checked, and nowhere in my code does it parent it somewhere else or destroy it. I even checked in the explorer and even the command bar and it did say that “Template” existed.

Maybe it’s not in MessageBox? Either that or MessageBox is incorrectly initialized.

I just stated that I checked via commandbar and the explorer and that it only occurs after the player resets/dies. If it was incorrectly initialized, the script wouldn’t work for a first time.

The output should not error if there was no issue with your code in the first place. Although everything is working fine, your code may be depending on objects that have not yet loaded into the game, which is why your code yielded. If your code yielded in a function, this will not stop the rest of the script from running. Please provide your code for others to examine.

As you can see, before I reset, the output shows no signs of errors.

Until of course the player resets.

The output states that the blade doesn’t exist yet the code still runs and kills players.
wait()

local Module = {}

local PlayersService = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local StarterGui = game:GetService("StarterGui")

local localPlayer = PlayersService.LocalPlayer
local Character = localPlayer.Character or localPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")

local Weapon = script.Parent.Parent
local Configuration = Weapon.Configuration

Weapon:WaitForChild("Blade")
Weapon:WaitForChild("Handle")

This is what I don’t get:

“Blade” does not exist yet the beam inside of it still activates when I swing it.
“Template” does not exist yet the template is still cloned and is seen on the chatbox displaying my messages.
“InputField” doesn’t exist yet I can still type in it when I press slash.

Do mind the chat is custom.

If I had to guess based on the information provided, it seems like you have the “ResetOnSpawn” property checked on the ScreenGui yet are not running new code on respawn? Or something to that effect.

Or, perhaps, you have two instances of the code/scripts running after respawn, and one of them not having a proper reference to your objects/ is referencing an object that was :Destroyed() on respawn. This would explain the script functioning yet erroring.

On your second screenshot I can see your script yields and errors on the same line twice which leads me to believe that the issue is that your script runs more than once.

That would explain why the game continues to function despite the errors: because among the scripts there’s one which didn’t error.

I am having an issue with modulescripts having errors. I beleive thats a plugin of mine, because when I start a new baseplate I still get that error. So try checking your plugins, and if it is a plugin try to wait for the error to be patched. Or delete / uninstall it if desired.

Plugins have a different stack trace in the output (unless the plugin parents modules to StarterGui and then requires them, which is unlikely).

1 Like

Could you provide more code samples so we can see what is happening within the code?

If the code errors but still seems to work, most likely you have multiple threads are running at the same time of which only some are working correctly.
If we’re looking at weapons then any threads created will most likely be in a section of code with a .Touched event or similar, but this of course is a guess as I don’t know the exact code at play here.

Also, the error is stating that “Blade is not a valid member of tool”, even though you have written “Weapon:WaitForChild(“Blade”)” at the beginning of the script. This suggests that the blade is being removed during runtime and the script is still trying to reference it somewhere. If this is happening when the player dies, maybe it’s to do with the blade falling out of the world to the PartDestroyHeight where the Handle, or Blade, is destroyed.

The chat issue is probably a similar scenario with different code.

That’s at least as much as I could try and deduce, I’d be happy to try and help more if you could supply more code or example :smiley:

Alright, so what is interesting is that it’s not actually my code that is doing this. For some odd reason, the PlayerGui is not resetting causing two of the same instances to be running.

I was able to come to this conclusion as the source was not available when clicking on the error (as it should always open). I’m trying to find a method to remove these errors from my output box.

It was also referenced here: LocalScript in Tool breaks when player respawns

wadawdawdaw

There’s clearly a redundant instance of my script that should be destroyed upon reset that has nothing to do with my code but I can’t figure out how to fix this.

Alright so apparently modulescripts continue to run despite it being destroyed.

If anyone comes to this issue as receiving redundant errors from an instance that is still running but is destroyed, disconnect your functions if it is in a module.

2 Likes