Funky 277 error, crashes server on wait()

Hey there! I’m currently experiencing a strange issue that I have never seen before, and have not found much info at all about online. I am working on a medical item that works akin to the herb-spray canisters from the Resident Evil series. There is a catch though; that the substance is flammable. If you are on fire and use it, the canister will explode.

When in studio, everything works perfectly fine, however when a player uses the item on themself ingame, the server freezes for a few seconds, and then kicks everyone while displaying an “Error 277” code. I do not get any errors in studio, and the processes work without any issue. My code goes as follows:

local Tool = MyTool
local Used = true
local selfAnim = MyAnim1
local idleAnim = MyAnim2
local Sound = MySound
local PE = MyParticleEmitter
-- Stuff initialized earlier in the script

local Humanoid = Tool.Parent:FindFirstChild("Humanoid")
if Humanoid and Humanoid.Health < Humanoid.MaxHealth then
	Used = true
--  Boolean to stop spam, earlier in the code
	selfAnim:Play()
	Sound:Play()
	PE.Enabled = true
--  Play animation, sound, and start the emitter
	wait(0.5)
--  This wait doesn't trigger the 277 error
	if Humanoid.Parent:FindFirstChild("FireParticle", true) ~= nil then
--      If the character has fire in it
		local ExSound = Tool.Handle.Explode
		ExSound:Play()
--      Play the explode sound
		local Explode = Instance.new("Explosion", workspace)
		Explode.BlastPressure = 0
		Explode.BlastRadius = 0
		Explode.Position = Tool.Handle.Position
--      Make a nonlethal explosion
		Humanoid:TakeDamage(100)
--      Kill or severely injure the player
--		wait(1)-------------------------------------------------------
--      Wait a bit for the sound and explosion to end, then destroy the tool
		Tool:Destroy()
	else
--      Else if the character is not on fire
--		wait(1)-------------------------------------------------------
		PE.Enabled = false
--      Wait a bit and stop the emitter and sound
		Sound:Stop()
--		wait(1)-------------------------------------------------------
--      Wait a moment so the particles have time to fade away
		idleAnim:Stop()
		if Tool.Parent.ClassName ~= "Backpack" then
--          If the user still has the tool in their hand, then move a healing script into their character, as well as destroy the tool
			local Healer = script.Healer:Clone()
			Healer.Parent = Humanoid.Parent
			Healer.Disabled = false
			Tool:Destroy()
		end
	end
end

You may have taken notice that my wait(1) lines are commented out. For some reason, this seems to make the error not occur. If I uncomment the wait lines, the server crashes. The server will crash regardless of what user activates this code. Though, I kind of need these waits in order to make the item not instantly usable, and to give the affects time to fade away.

I am completely dumbfounded as to what is going on. When I searched around online for ‘error 277’ things, all I could find are vague references to servers running out of memory. This doesn’t make sense to me though, as this happens when no other code has run yet, and the server has just opened up. Also, I will add just in case anyone asks, this is the only code running at the time. Nothing in the background, no spawn()s, or anything. This also only affects ingame, playtesting in Studio does not produce this error. This originally made me think this could be a server/client issue, and was not affecting me since Studio merges the two. I don’t think this is the case though, as all of the code above is ran in a single server script.

I don’t quite have an answer to provide here because I too haven’t a clue what’s going on, been scrolling through your code trying to find a vector for the crashes. On the other hand, there’s something I’d like to point out, a misconception.

For years now, Studio has separated the client and the server through the advent of a feature called Accurate Play Solo. This now the default and forced method of testing. The legacy method where the client and the server serve as a single entity is deprecated and gone.

That is indeed a very weird issue. Does it happen in the Test Server mode on studio as well?
Can you perhaps make a repro and send it as a roblox studio file?

I just pulled the tool into a separate place, and it still produces the error ingame. Here is the place file. 277 error.rbxl (23.5 KB)

Once again, it works completely fine in both the studio test mode and the studio server test, however, when I right-mouse the tool in the actual game, the server freezes, crashes, and displays that 277 error.
Additionally, after a server has crashed, if I try to rejoin, it will kick me and display an “error code 279”
Here are some screenshots of exactly what I get:

  • When you heal yourself
    first
  • When you try to rejoin
    second

According to this website, a 277 can happen when a client loses connection or when your local government blocks Roblox (I can’t think of any that do though). A 279 happens when the client was unable to join the server, this will require the player to wait some minutes to rejoin the game. This usually occurs after players get disconnected and need to rejoin the game or join another game.

The 277 also states, though, that recently this has been an issue occurring randomly, with seemingly no cause. My best guess is that there’s some bug in Roblox caused by some combination of scripts that we’re unaware of.

Then again, this website isn’t an official website, so take that with a grain of salt.

Played around with this a lot in Roblox Studio. After a very long ang agonising time of experimenting, changing conclusions and retyping a response to this thread, I found the source of error; it’s because you’re using a RemoteFunction and not a RemoteEvent. Instantly killed 277 errors after the change.

The RemoteFunction itself is causing problems because your networking model is wrong. RemoteFunctions should only be used when you care about what the invoked environment sends back to the invoking environment. Your tool’s client doesn’t need a response from the server, thus making a RemoteFunction unnecessary in this case.

What’s happening is the client script is expecting a return value from the server when it invokes the remote. The server doesn’t return any values at any point in its calling. Therefore, every time you send input to UserInputService via a mouse button, you now have several infinitely yielded function scopes.

In response to the above, I attempted to add a return value. That didn’t alleviate the problem. The tool is destroyed before the server has any chance to return values and even if it does return values, it’s sending input back to an invalidated thread. This network traffic confusion causes the crash.

[tl;dr] You used the wrong type of remote.

error277 repro fix.rbxl (23.8 KB)

5 Likes

I hadn’t known you could pass values through a RemoteEvent. I’ve always thought the different between an Event and a Function was if it fired something, or passed values along. I haven’t experienced any issues previously, so I never actually read the API for them. My apologies, and thank you!