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

I get this error in the output ( in the desc ) how do i fix it?

" 12:43:55.808 - BindToClose failed because the model is already being closed."

local bindableEvent = Instance.new("BindableEvent")

game.Players.PlayerRemoving:Connect(function(player)
	
	pcall(function()
		dataStores:SetAsync(player.UserId.."-Bucks",player.leaderstats.Bucks.Value)
		print ("Saved")
		playersLeft = playersLeft - 1
		bindableEvent:Fire()
	end)
	
	
	game:BindToClose(function()
		--Upon shutdown, this will be triggered
		while playersLeft > 0 do
			bindableEvent.Event:Wait()
		end
	end)
	
end)

1 answer

Don't put BindToClose inside playerRemvoing put it outside the connected function each time a player leaves that function gets binded what then results in that error

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